first commit
This commit is contained in:
1351
autoload/Savant3.php
Normal file
1351
autoload/Savant3.php
Normal file
File diff suppressed because it is too large
Load Diff
27
autoload/admin/controls/class.Adverts.php
Normal file
27
autoload/admin/controls/class.Adverts.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
namespace admin\controls;
|
||||
|
||||
class Adverts {
|
||||
|
||||
public static function getContent()
|
||||
{
|
||||
$rw = \System::formGet( 'rw' );
|
||||
|
||||
if ( $rw == 'del' )
|
||||
{
|
||||
if ( \admin\factory\Adverts::deleteAdvert( \System::formGetInt( 'id' ) ) )
|
||||
\System::setAlert( 'Reklama została usunięta.' );
|
||||
header( 'Location: ./' );
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( $rw == 'edit' )
|
||||
return \admin\view\Adverts::editAdvert( \System::formGetInt( 'id' ) );
|
||||
|
||||
if ( $rw == 'add' )
|
||||
return \admin\view\Adverts::editAdvert();
|
||||
|
||||
return \admin\view\Adverts::showAdverts();
|
||||
}
|
||||
}
|
||||
?>
|
||||
105
autoload/admin/controls/class.Articles.php
Normal file
105
autoload/admin/controls/class.Articles.php
Normal file
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
namespace admin\controls;
|
||||
|
||||
class Articles
|
||||
{
|
||||
public static function getContentArticleSort()
|
||||
{
|
||||
return \admin\view\Articles::drawPagesArticles();
|
||||
}
|
||||
|
||||
public static function getContentArticlesArchive()
|
||||
{
|
||||
$rw = \System::formGet( 'rw' );
|
||||
|
||||
if ( $rw == 'show' )
|
||||
return false;
|
||||
else
|
||||
{
|
||||
if ( $rw == 'restore' && \admin\factory\Articles::restoreArticle( \System::formGetInt( 'id' ) ) )
|
||||
{
|
||||
\System::setAlert( 'Artykuł został przywrócony.' );
|
||||
header( 'Location: ./' );
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( $rw == 'del' && \admin\factory\Articles::deleteArticle( \System::formGetInt( 'id' ) ) )
|
||||
{
|
||||
\System::setAlert( 'Artykuł został usunięty.' );
|
||||
header( 'Location: ./' );
|
||||
exit;
|
||||
}
|
||||
|
||||
return \admin\view\Articles::showArticlesArchive();
|
||||
}
|
||||
}
|
||||
|
||||
public static function getContentArticles()
|
||||
{
|
||||
$rw = \System::formGet( 'rw' );
|
||||
|
||||
if ( \System::formGet( 'act' ) )
|
||||
{
|
||||
\System::setSessionVar( 'act' , \System::formGet( 'act' ) );
|
||||
\System::setSessionVar( 'art_id' , \System::formGet( 'id' ) );
|
||||
}
|
||||
|
||||
$act = \System::getSessionVar( 'act' );
|
||||
|
||||
if ( $act == 'show_versions' )
|
||||
{
|
||||
if ( $rw == 'restore' && \admin\factory\Articles::restoreArticleVersion( \System::formGetInt( 'id' ) ) )
|
||||
{
|
||||
\System::setAlert( 'Artykuł został przywrócony.' );
|
||||
header( 'Location: ./' );
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( $rw == 'show' )
|
||||
return \admin\view\Articles::drawArticle( \System::formGetInt( 'id' ) );
|
||||
|
||||
return \admin\view\Articles::showVersions( \System::getSessionVar( 'art_id' ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
\admin\factory\Articles::deleteNonAssignImages();
|
||||
|
||||
if ( $rw == 'change-enabled' && \admin\factory\Articles::changeArticleEnabled( \System::formGetInt( 'id' ) ) )
|
||||
{
|
||||
\System::setAlert( 'Widoczność artykułu została zmieniona.' );
|
||||
header( 'Location: ./' );
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( $rw == 'del' && \admin\factory\Articles::setAsArchive( \System::formGetInt( 'id' ) ) )
|
||||
{
|
||||
\System::setAlert( 'Artykuł został przeniesiony do archiwum.' );
|
||||
header( 'Location: ./' );
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( $rw == 'save' && \admin\factory\Articles::saveArticle() )
|
||||
{
|
||||
\System::setAlert( 'Artykuł został zapisany.' );
|
||||
header( 'Location: ./' );
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( $rw == 'add_new' && \admin\factory\Articles::addArticle() )
|
||||
{
|
||||
\System::setAlert( 'Artykuł został dodany.' );
|
||||
header( 'Location: ./' );
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( $rw == 'edit' )
|
||||
return \admin\view\Articles::editArticle( \System::formGetInt( 'id' ) );
|
||||
|
||||
if ( $rw == 'add' )
|
||||
return \admin\view\Articles::addArticle();
|
||||
|
||||
return \admin\view\Articles::showArticles();
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
40
autoload/admin/controls/class.Banners.php
Normal file
40
autoload/admin/controls/class.Banners.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?
|
||||
namespace admin\controls;
|
||||
|
||||
class Banners
|
||||
{
|
||||
public function getContent()
|
||||
{
|
||||
$rw = \System::formGet( 'rw' );
|
||||
|
||||
if ( $rw == 'down' && \admin\factory\Banners::moveBannerDown( \System::formGetInt( 'id' ) ) )
|
||||
{
|
||||
\System::setAlert( 'Baner został przesunięty w dół.' );
|
||||
header( 'Location: ./' );
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( $rw == 'up' && \admin\factory\Banners::moveBannerUp( \System::formGetInt( 'id' ) ) )
|
||||
{
|
||||
\System::setAlert( 'Baner został przesunięty w górę' );
|
||||
header( 'Location: ./' );
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( $rw == 'del' && \admin\factory\Banners::deleteBanner( \System::formGetInt( 'id' ) ) )
|
||||
{
|
||||
\System::setAlert( 'Baner został usunięty.' );
|
||||
header( 'Location: ./' );
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( $rw == 'edit' )
|
||||
return \admin\view\Banners::editBanner( \System::formGetInt( 'id' ) );
|
||||
|
||||
if ( $rw == 'add' )
|
||||
return \admin\view\Banners::editBanner();
|
||||
|
||||
return \admin\view\Banners::showBanners();
|
||||
}
|
||||
}
|
||||
?>
|
||||
11
autoload/admin/controls/class.Filemanager.php
Normal file
11
autoload/admin/controls/class.Filemanager.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
namespace admin\controls;
|
||||
|
||||
class Filemanager {
|
||||
|
||||
public function getContent()
|
||||
{
|
||||
return \admin\view\FileManager::showFileManager();
|
||||
}
|
||||
}
|
||||
?>
|
||||
26
autoload/admin/controls/class.GuestBook.php
Normal file
26
autoload/admin/controls/class.GuestBook.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?
|
||||
namespace admin\controls;
|
||||
|
||||
class GuestBook
|
||||
{
|
||||
public function getContent()
|
||||
{
|
||||
$rw = \System::formGet( 'rw' );
|
||||
|
||||
if ( $rw == 'del' && \admin\factory\GuestBook::deleteEntry( \System::formGetInt( 'id' ) ) )
|
||||
{
|
||||
\System::setAlert( 'Usunięto wpis z księgi gości.' );
|
||||
header( 'Location: ./' );
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( $rw == 'edit' )
|
||||
return \admin\view\GuestBook::editEntry( \System::formGetInt( 'id' ) );
|
||||
|
||||
if ( $rw == 'add' )
|
||||
return \admin\view\GuestBook::editEntry();
|
||||
|
||||
return \admin\view\GuestBook::showEntries();
|
||||
}
|
||||
}
|
||||
?>
|
||||
37
autoload/admin/controls/class.Languages.php
Normal file
37
autoload/admin/controls/class.Languages.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?
|
||||
// po poprawkach
|
||||
namespace admin\controls;
|
||||
|
||||
class Languages
|
||||
{
|
||||
public function getContentTranslation()
|
||||
{
|
||||
$rw = \System::formGet( 'rw' );
|
||||
|
||||
if ( $rw == 'del' && \admin\factory\Languages::deleteTranslation( \System::formGetInt( 'id' ) ) )
|
||||
{
|
||||
\System::setAlert( 'Tłumaczenie zostało usunięte.' );
|
||||
header( 'Location: ./' );
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( $rw == 'edit' )
|
||||
return \admin\view\Languages::editTranslation( \System::formGetInt( 'id' ) );
|
||||
|
||||
if ( $rw == 'add' )
|
||||
return \admin\view\Languages::editTranslation();
|
||||
|
||||
return \admin\view\Languages::showTranslations();
|
||||
}
|
||||
|
||||
public function getContentLanguages()
|
||||
{
|
||||
$rw = \System::formGet( 'rw' );
|
||||
|
||||
if ( $rw == 'edit' )
|
||||
return \admin\view\Languages::editLanguage( \System::formGet( 'id' ) );
|
||||
|
||||
return \admin\view\Languages::showLanguages();
|
||||
}
|
||||
}
|
||||
?>
|
||||
40
autoload/admin/controls/class.Layouts.php
Normal file
40
autoload/admin/controls/class.Layouts.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
namespace admin\controls;
|
||||
|
||||
class Layouts {
|
||||
|
||||
public static function getContent()
|
||||
{
|
||||
$rw = \System::formGet( 'rw' );
|
||||
|
||||
if ( $rw == 'del' && \admin\factory\Layouts::deleteLayout( \System::formGetInt( 'id' ) ) )
|
||||
{
|
||||
\System::setAlert( 'Szablon został usunięty.' );
|
||||
header( 'Location: ./' );
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( $rw == 'save_new' && \admin\factory\Layouts::addLayout() )
|
||||
{
|
||||
\System::setAlert( 'Szablon został dodany.' );
|
||||
header( 'Location: ./' );
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( $rw == 'save' && \admin\factory\Layouts::saveLayout() )
|
||||
{
|
||||
\System::setAlert( 'Szablon został zapisany.' );
|
||||
header( 'Location: ./' );
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( $rw == 'edit' )
|
||||
return \admin\view\Layouts::editLayout( \System::formGetInt( 'id' ) );
|
||||
|
||||
if ( $rw == 'add' )
|
||||
return \admin\view\Layouts::addLayout();
|
||||
|
||||
return \admin\view\Layouts::showLayouts();
|
||||
}
|
||||
}
|
||||
?>
|
||||
21
autoload/admin/controls/class.Newsletter.php
Normal file
21
autoload/admin/controls/class.Newsletter.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
namespace admin\controls;
|
||||
|
||||
class Newsletter {
|
||||
|
||||
public function getContentEmails()
|
||||
{
|
||||
$rw = \System::formGet( 'rw' );
|
||||
|
||||
if ( $rw == 'del' && \admin\factory\Newsletter::deleteEmail( \System::formGetInt( 'id' ) ) )
|
||||
\System::setAlert( 'Wybrany email został usunięty.' );
|
||||
|
||||
if ( $rw == 'add' )
|
||||
return \admin\view\Newsletter::editEmail();
|
||||
|
||||
if ( $rw == 'edit' )
|
||||
return \admin\view\Newsletter::editEmail( \System::formGetInt( 'id' ) );
|
||||
|
||||
return \admin\view\Newsletter::showEmailList();
|
||||
}
|
||||
}
|
||||
134
autoload/admin/controls/class.Page.php
Normal file
134
autoload/admin/controls/class.Page.php
Normal file
@@ -0,0 +1,134 @@
|
||||
<?php
|
||||
namespace admin\controls;
|
||||
|
||||
class Page {
|
||||
|
||||
public static function checkUrlParams()
|
||||
{
|
||||
global $user;
|
||||
|
||||
$rw = \System::formGet( 'rw' );
|
||||
|
||||
switch ( $rw )
|
||||
{
|
||||
case 'user_logon':
|
||||
$user = \user\FUser::Login( \System::formGet( 'login' ), \System::formGet( 'password' ) );
|
||||
\System::setSessionVar( 'user', $user, true );
|
||||
break;
|
||||
|
||||
case 'user_logout':
|
||||
\System::deleteSessionVar( 'user' , true );
|
||||
break;
|
||||
|
||||
case 'db_edit_save':
|
||||
$db_edit_table = \System::getSessionVar( 'db_edit_table' );
|
||||
$db_edit_key = \System::getSessionVar( 'db_edit_key' );
|
||||
$db_edit_val = \System::getSessionVar( 'db_edit_val' );
|
||||
$db_edit_pols = \System::getSessionVar( 'db_edit_pols' );
|
||||
$db_edit_pass = \System::getSessionVar( 'db_edit_pass' );
|
||||
$db_edit_pols_t = \System::getSessionVar( 'db_edit_pols_type' );
|
||||
\DataBase::SaveData( $db_edit_table , $db_edit_key , $db_edit_val , $db_edit_pols , $db_edit_pass , $db_edit_pols_t );
|
||||
break;
|
||||
|
||||
case 'db_edit_add_new':
|
||||
$db_edit_table = \System::getSessionVar( 'db_edit_table' );
|
||||
$db_edit_pols = \System::getSessionVar( 'db_edit_pols' );
|
||||
$db_edit_pass = \System::getSessionVar( 'db_edit_pass' );
|
||||
$db_edit_pols_hidden = \System::getSessionVar( 'db_edit_pols_hidden' );
|
||||
$db_edit_pols_t = \System::getSessionVar( 'db_edit_pols_type' );
|
||||
$time = \System::formGetHash( 'time' );
|
||||
\DataBase::AddData( $db_edit_table , $db_edit_pols , $db_edit_pols_hidden , $db_edit_pols_t , $time , $db_edit_pass );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static function getContent()
|
||||
{
|
||||
global $user;
|
||||
|
||||
if ( !$user || !$user -> _values['admin'] )
|
||||
return \admin\view\Users::drawLoginForm();
|
||||
|
||||
if ( \System::formGet( 'p' ) )
|
||||
\System::setSessionVar( 'page_type' , \System::formGet( 'p' ) );
|
||||
|
||||
$page_type = \System::getSessionVar( 'page_type' );
|
||||
|
||||
switch ( $page_type )
|
||||
{
|
||||
case 'newsletter_emails':
|
||||
return \admin\controls\Newsletter::getContentEmails();
|
||||
break;
|
||||
|
||||
case 'static_containers':
|
||||
return \admin\controls\SContainers::getContent();
|
||||
break;
|
||||
|
||||
case 'filemanager':
|
||||
return \admin\controls\Filemanager::getContent();
|
||||
break;
|
||||
|
||||
case 'adverts':
|
||||
return \admin\controls\Adverts::getContent();
|
||||
break;
|
||||
|
||||
case 'page_article_sort':
|
||||
return \admin\controls\Articles::getContentArticleSort();
|
||||
break;
|
||||
|
||||
case 'users':
|
||||
return \admin\controls\Users::getContentUsers();
|
||||
break;
|
||||
|
||||
case 'article_archive':
|
||||
return \admin\controls\Articles::getContentArticlesArchive();
|
||||
break;
|
||||
|
||||
case 'page_definition':
|
||||
return \admin\controls\Pages::getContent();
|
||||
break;
|
||||
|
||||
case 'page_articles':
|
||||
default;
|
||||
return \admin\controls\Articles::getContentArticles();
|
||||
break;
|
||||
|
||||
case 'admins':
|
||||
return \admin\controls\Users::getContentAdmins();
|
||||
break;
|
||||
|
||||
case 'lang':
|
||||
return \admin\controls\Languages::getContentLanguages();
|
||||
break;
|
||||
|
||||
case 'translation':
|
||||
return \admin\controls\Languages::getContentTranslation();
|
||||
break;
|
||||
|
||||
case 'settings':
|
||||
return \admin\controls\Settings::getContent();
|
||||
break;
|
||||
|
||||
case 'guest_book':
|
||||
return \admin\controls\GuestBook::getContent();
|
||||
break;
|
||||
|
||||
case 'banner':
|
||||
return \admin\controls\Banners::getContent();
|
||||
break;
|
||||
|
||||
case 'layout':
|
||||
return \admin\controls\Layouts::getContent();
|
||||
break;
|
||||
|
||||
case 'banned_email':
|
||||
return \admin\controls\Restriction::getContentEmails();
|
||||
break;
|
||||
|
||||
case 'banned_login':
|
||||
return \admin\controls\Restriction::getContentLogins();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
52
autoload/admin/controls/class.Pages.php
Normal file
52
autoload/admin/controls/class.Pages.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
namespace admin\controls;
|
||||
|
||||
class Pages {
|
||||
|
||||
public static function getContent()
|
||||
{
|
||||
$rw = \System::formGet( 'rw' );
|
||||
|
||||
if ( $rw == 'del_menu' )
|
||||
{
|
||||
\admin\factory\Menu::deleteMenu( \System::formGetInt( 'id' ) );
|
||||
header( 'Location: ./' );
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( $rw == 'save' && \admin\factory\Pages::savePage() )
|
||||
{
|
||||
\System::setAlert( 'Strona została zapisana.' );
|
||||
header( 'Location: ./' );
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( $rw == 'add_new' && \admin\factory\Pages::addPage() )
|
||||
{
|
||||
\System::setAlert( 'Strona została dodana.' );
|
||||
header( 'Location: ./' );
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( $rw == 'add_menu' )
|
||||
return \admin\view\Menu::editMenu();
|
||||
|
||||
if ( $rw == 'edit_menu' )
|
||||
return \admin\view\Menu::editMenu( \System::formGetInt( 'id' ) );
|
||||
|
||||
if ( $rw == 'edit' )
|
||||
return \admin\view\Pages::editPage( \System::formGet( 'id' ), \System::formGetInt( 'menu_id' ) );
|
||||
|
||||
if ( $rw == 'add' )
|
||||
return \admin\view\Pages::addPage( \System::formGetInt( 'menu_id' ), \System::formGetInt( 'parent_id' ) );
|
||||
|
||||
if ( $rw == 'article_list' )
|
||||
return \admin\view\Pages::showAssignedArticles( \System::formGetInt( 'id' ) );
|
||||
|
||||
if ( $rw == 'del' )
|
||||
\admin\factory\Pages::deletePage( \System::formGetInt( 'id' ) );
|
||||
|
||||
return \admin\view\Pages::showPages();
|
||||
}
|
||||
}
|
||||
?>
|
||||
39
autoload/admin/controls/class.Restriction.php
Normal file
39
autoload/admin/controls/class.Restriction.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?
|
||||
// po poprawkach
|
||||
namespace admin\controls;
|
||||
|
||||
class Restriction
|
||||
{
|
||||
public function getContentEmails()
|
||||
{
|
||||
$rw = \System::formGet( 'rw' );
|
||||
|
||||
if ( $rw == 'edit' )
|
||||
return \admin\view\Restriction::editBannedEmail( \System::formGet( 'id' ) );
|
||||
|
||||
if ( $rw == 'add' )
|
||||
return \admin\view\Restriction::editBannedEmail();
|
||||
|
||||
if ( $rw == 'del' )
|
||||
\admin\factory\Restriction::deleteBannedEmail( \System::formGet( 'id' ) );
|
||||
|
||||
return \admin\view\Restriction::showBannedEmails();
|
||||
}
|
||||
|
||||
public function getContentLogins()
|
||||
{
|
||||
$rw = \System::formGet( 'rw' );
|
||||
|
||||
if ( $rw == 'edit' )
|
||||
return \admin\view\Restriction::editBannedLogin( \System::formGet( 'id' ) );
|
||||
|
||||
if ( $rw == 'add' )
|
||||
return \admin\view\Restriction::editBannedLogin();
|
||||
|
||||
if ( $rw == 'del' )
|
||||
\admin\factory\Restriction::deleteBannedLogin( \System::formGet( 'id' ) );
|
||||
|
||||
return \admin\view\Restriction::showBannedLogins();
|
||||
}
|
||||
}
|
||||
?>
|
||||
27
autoload/admin/controls/class.SContainers.php
Normal file
27
autoload/admin/controls/class.SContainers.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
namespace admin\controls;
|
||||
|
||||
class SContainers {
|
||||
|
||||
public function getContent()
|
||||
{
|
||||
$rw = \System::formGet( 'rw' );
|
||||
|
||||
if ( $rw == 'del' && \admin\factory\SContainers::deleteContainer( \System::formGetInt( 'id' ) ) )
|
||||
\System::setAlert( 'Wybrany kontener został usunięty.' );
|
||||
|
||||
if ( $rw == 'edit' )
|
||||
return \admin\view\SContainers::editContainer( \System::formGet( 'id' ) );
|
||||
|
||||
if ( $rw == 'add' )
|
||||
return \admin\view\SContainers::editContainer();
|
||||
|
||||
if ( $rw == 'save' )
|
||||
\admin\factory\SContainers::saveContainer();
|
||||
|
||||
if ( $rw == 'save_new')
|
||||
\admin\factory\SContainers::addContainer();
|
||||
|
||||
return \admin\view\SContainers::showContainerList();
|
||||
}
|
||||
}
|
||||
16
autoload/admin/controls/class.Settings.php
Normal file
16
autoload/admin/controls/class.Settings.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?
|
||||
namespace admin\controls;
|
||||
|
||||
class Settings
|
||||
{
|
||||
public static function getContent()
|
||||
{
|
||||
$rw = \System::formGet( 'rw' );
|
||||
|
||||
if ( $rw == 'save_settings' )
|
||||
\admin\factory\Settings::saveSettings();
|
||||
|
||||
return \admin\view\Settings::showSettings();
|
||||
}
|
||||
}
|
||||
?>
|
||||
39
autoload/admin/controls/class.Users.php
Normal file
39
autoload/admin/controls/class.Users.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
//po poprawkach
|
||||
namespace admin\controls;
|
||||
|
||||
class Users {
|
||||
|
||||
public function getContentAdmins()
|
||||
{
|
||||
$rw = \System::formGet( 'rw' );
|
||||
|
||||
if ( $rw == 'add' )
|
||||
return \admin\view\Users::editAdmin();
|
||||
|
||||
if ( $rw == 'edit' )
|
||||
return \admin\view\Users::editAdmin( \System::formGetInt( 'id' ) );
|
||||
|
||||
if ( $rw == 'del' )
|
||||
\admin\factory\Users::deleteAdmin( \System::formGetInt( 'id' ) );
|
||||
|
||||
return \admin\view\Users::showAdmins();
|
||||
}
|
||||
|
||||
public function getContentUsers()
|
||||
{
|
||||
$rw = \System::formGet( 'rw' );
|
||||
|
||||
if ( $rw == 'add' )
|
||||
return \admin\view\Users::editUser();
|
||||
|
||||
if ( $rw == 'edit' )
|
||||
return \admin\view\Users::editUser( \System::formGetInt( 'id' ) );
|
||||
|
||||
if ( $rw == 'del' )
|
||||
\admin\factory\Users::deleteUser( \System::formGetInt( 'id' ) );
|
||||
|
||||
return \admin\view\Users::showUsers();
|
||||
}
|
||||
}
|
||||
?>
|
||||
61
autoload/admin/factory/class.Adverts.php
Normal file
61
autoload/admin/factory/class.Adverts.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
namespace admin\factory;
|
||||
|
||||
class Adverts {
|
||||
|
||||
public static function getAcitveAdvert()
|
||||
{
|
||||
global $db, $config, $cache;
|
||||
|
||||
$key = 'getAcitveAdvert';
|
||||
|
||||
if ( !$advert = $cache -> fetch( $key ) )
|
||||
{
|
||||
$query = $db -> query( 'SELECT * FROM pp_adverts WHERE ( date_start <= "' . date( 'Y-m-d' ) . '" OR date_start = "0000-00-00" ) AND ( date_end >= "' . date( 'Y-m-d' ) . '" OR date_end = "0000-00-00" ) AND enabled = 1 LIMIT 1' );
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
$advert = $row;
|
||||
$query -> closeCursor();
|
||||
|
||||
$cache -> store( $key, $advert, $config['cache_expire'] );
|
||||
}
|
||||
return $advert;
|
||||
}
|
||||
|
||||
public static function deleteAdvert( $id )
|
||||
{
|
||||
global $db;
|
||||
|
||||
try
|
||||
{
|
||||
$db -> beginTransaction();
|
||||
|
||||
$query = $db -> prepare( 'SELECT image FROM pp_adverts WHERE id = :id' );
|
||||
$query -> bindValue( ':id' , $id , \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
if ( file_exists( '../' . $row['image'] ) )
|
||||
unlink( '../' . $row['image'] );
|
||||
|
||||
$query2 = $db -> prepare( 'DELETE FROM pp_adverts WHERE id = :id' );
|
||||
$query2 -> bindValue( ':id' , $id , \PDO::PARAM_INT );
|
||||
$query2 -> execute();
|
||||
$query2 -> closeCursor();
|
||||
}
|
||||
$query -> closeCursor();
|
||||
|
||||
$db -> commit();
|
||||
|
||||
\System::deleteCacheAdmin();
|
||||
\System::deleteCache();
|
||||
return true;
|
||||
}
|
||||
catch ( \PDOException $ex )
|
||||
{
|
||||
$db -> rollBack();
|
||||
\System::setAlert( 'Błąd: ' . $ex -> getMessage() );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
?>
|
||||
680
autoload/admin/factory/class.Articles.php
Normal file
680
autoload/admin/factory/class.Articles.php
Normal file
@@ -0,0 +1,680 @@
|
||||
<?php
|
||||
// po poprawkach
|
||||
namespace admin\factory;
|
||||
|
||||
class Articles {
|
||||
|
||||
public static function cloneArticle( $id )
|
||||
{
|
||||
global $db;
|
||||
if ( $art_id = \System::duplicateMysqlRow( 'pp_articles', 'id', $id, array( 'date_add' ) ) )
|
||||
{
|
||||
$query = $db -> prepare( 'SELECT id FROM pp_articles_langs WHERE article_id = :article_id' );
|
||||
$query -> bindValue( ':article_id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
if ( $lang_id = \System::duplicateMysqlRow( 'pp_articles_langs', 'id', $row['id'], array( 'seo_link', 'date_modify' ) ) )
|
||||
{
|
||||
$query2 = $db -> prepare( 'UPDATE pp_articles_langs SET article_id = :article_id WHERE id = :id' );
|
||||
$query2 -> bindValue( ':article_id', $art_id, \PDO::PARAM_INT );
|
||||
$query2 -> bindValue( ':id', $lang_id, \PDO::PARAM_INT );
|
||||
$query2 -> execute();
|
||||
$query2 -> closeCursor();
|
||||
|
||||
$query2 = $db -> prepare( 'UPDATE pp_articles SET date_modify = :date_modify WHERE id = :id' );
|
||||
$query2 -> bindValue( ':id', $art_id, \PDO::PARAM_INT );
|
||||
$query2 -> bindValue( ':date_modify', \System::getDate(), \PDO::PARAM_INT );
|
||||
$query2 -> execute();
|
||||
$query2 -> closeCursor();
|
||||
|
||||
$query2 = $db -> prepare( 'UPDATE pp_articles SET thumbnail = NULL WHERE id = :id' );
|
||||
$query2 -> bindValue( ':id', $art_id, \PDO::PARAM_INT );
|
||||
$query2 -> execute();
|
||||
$query2 -> closeCursor();
|
||||
}
|
||||
}
|
||||
$query -> closeCursor();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function changeArticleEnabled( $id )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'SELECT enabled FROM pp_articles WHERE id = :id' );
|
||||
$query -> bindValue( ':id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
$enabled = $row['enabled'];
|
||||
$query -> closeCursor();
|
||||
|
||||
$enabled ? $enabled_new = 0 : $enabled_new = 1;
|
||||
|
||||
$query = $db -> prepare( 'UPDATE pp_articles SET enabled = :enabled WHERE id = :id' );
|
||||
$query -> bindValue( ':id', $id, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':enabled', $enabled_new, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() )
|
||||
return true;
|
||||
$query -> closeCursor();
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function getPagesWithArticles()
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'SELECT id FROM pp_pages ORDER BY id_menu ASC, o ASC' );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
unset( $articles );
|
||||
|
||||
$row['title'] = \admin\factory\Pages::getPageTitle( $row['id'] );
|
||||
|
||||
$query2 = $db -> query( 'SELECT article_id AS id FROM pp_articles_pages AS pap, pp_articles AS pa WHERE pa.id = pap.article_id AND page_id = ' . $row['id'] . ' AND archive = 0 ORDER BY o ASC' );
|
||||
if ( $query2 -> rowCount() ) while ( $row2 = $query2 -> fetch() )
|
||||
{
|
||||
$row2['title'] = \System::getArticleTitle( $row2['id'] );
|
||||
$articles[] = $row2;
|
||||
}
|
||||
$query2 -> closeCursor();
|
||||
|
||||
$row['articles'] = $articles;
|
||||
$pages[] = $row;
|
||||
}
|
||||
$query -> closeCursor();
|
||||
|
||||
return $pages;
|
||||
}
|
||||
|
||||
public static function deleteArticle( $id )
|
||||
{
|
||||
global $db;
|
||||
|
||||
\System::deleteCache( '../upload/files/article_' . $id . '/' );
|
||||
\System::deleteCache( '../upload/galeries/article_' . $id . '/' );
|
||||
|
||||
$query = $db -> prepare( 'SELECT thumbnail FROM pp_articles WHERE id = :id AND thumbnail IS NOT NULL' );
|
||||
$query -> bindValue( ':id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
if ( file_exists( "../" . $row['thumbnail'] ) )
|
||||
unlink( "../" . $row['thumbnail'] );
|
||||
}
|
||||
$query -> closeCursor();
|
||||
|
||||
$query = $db -> prepare( 'DELETE FROM pp_articles_pages WHERE article_id = :id' );
|
||||
$query -> bindValue( ':id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
$query -> closeCursor();
|
||||
|
||||
$query = $db -> prepare( 'DELETE FROM pp_articles_langs WHERE article_id = :id' );
|
||||
$query -> bindValue( ':id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
$query -> closeCursor();
|
||||
|
||||
$query = $db -> prepare( 'DELETE FROM pp_articles_img WHERE id_article = :id_article' );
|
||||
$query -> bindValue( ':id_article', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
$query -> closeCursor();
|
||||
|
||||
$query = $db -> prepare( 'DELETE FROM pp_articles_file WHERE id_article = :id_article' );
|
||||
$query -> bindValue( ':id_article', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
$query -> closeCursor();
|
||||
|
||||
$query = $db -> prepare( 'DELETE FROM pp_articles WHERE id = :id' );
|
||||
$query -> bindValue( ':id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() )
|
||||
{
|
||||
\System::rewriteHtacces();
|
||||
\System::deleteCache();
|
||||
\System::deleteCacheAdmin();
|
||||
return true;
|
||||
}
|
||||
$query -> closeCursor();
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function restoreArticle( $id )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'UPDATE pp_articles SET archive = 0 WHERE id = :id' );
|
||||
$query -> bindValue( ':id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() )
|
||||
{
|
||||
\System::rewriteHtacces();
|
||||
\System::deleteCache();
|
||||
\System::deleteCacheAdmin();
|
||||
return true;
|
||||
}
|
||||
$query -> closeCursor();
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function getArticleFiles( $id )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'SELECT * FROM pp_articles_file WHERE id_article = :id_article' );
|
||||
$query -> bindValue( ':id_article', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
$files[] = $row;
|
||||
$query -> closeCursor();
|
||||
|
||||
return $files;
|
||||
}
|
||||
|
||||
public static function getArticleImages( $id )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'SELECT * FROM pp_articles_img WHERE id_article = :id_article' );
|
||||
$query -> bindValue( ':id_article', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
$images[] = $row;
|
||||
$query -> closeCursor();
|
||||
|
||||
return $images;
|
||||
}
|
||||
|
||||
public static function deleteNonAssignImages()
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> query( 'SELECT * FROM pp_articles_img WHERE id_article = 0' );
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
if ( file_exists( "../" . $row['src'] ) )
|
||||
unlink( "../" . $row['src'] );
|
||||
}
|
||||
$query -> closeCursor();
|
||||
|
||||
$query = $db -> query( 'DELETE FROM pp_articles_img WHERE id_article = 0' );
|
||||
$query -> closeCursor();
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function getArticleVersionByVersionId( $version_id )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'SELECT version FROM pp_articles_langs WHERE id = :id' );
|
||||
$query -> bindValue( ':id', $version_id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
return $row['version'];
|
||||
$query -> closeCursor();
|
||||
}
|
||||
|
||||
public static function getArticleIdByVersionId( $version_id )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'SELECT article_id FROM pp_articles_langs WHERE id = :id' );
|
||||
$query -> bindValue( ':id', $version_id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
return $row['article_id'];
|
||||
$query -> closeCursor();
|
||||
}
|
||||
|
||||
public static function getMaxArticleVersion( $id )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'SELECT MAX( version ) FROM pp_articles_langs WHERE article_id = :article_id' );
|
||||
$query -> bindValue( ':article_id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
return $row[0];
|
||||
$query -> closeCursor();
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static function restoreArticleVersion( $version_id )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$article_id = \admin\factory\Articles::getArticleIdByVersionId( $version_id );
|
||||
$version = \admin\factory\Articles::getArticleVersionByVersionId( $version_id );
|
||||
|
||||
$query = $db -> prepare( 'SELECT * FROM pp_articles_langs WHERE article_id = :article_id AND version = :version' );
|
||||
$query -> bindValue( ':article_id', $article_id, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':version', $version, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
if ( !$max_ver )
|
||||
$max_ver = self::getMaxArticleVersion( $row['article_id'] ) + 1;
|
||||
|
||||
$query2 = $db -> prepare( 'INSERT INTO pp_articles_langs ( text, meta_description, meta_keywords, title, article_id, lang_id, version ) VALUES ( :text, :meta_description, :meta_keywords, :title, :article_id, :lang_id, :version )' );
|
||||
$query2 -> bindValue( ':text', $row['text'], \PDO::PARAM_STR );
|
||||
$query2 -> bindValue( ':meta_description', $row['meta_description'], \PDO::PARAM_STR );
|
||||
$query2 -> bindValue( ':meta_keywords', $row['meta_keywords'], \PDO::PARAM_STR );
|
||||
$query2 -> bindValue( ':title', $row['title'], \PDO::PARAM_STR );
|
||||
$query2 -> bindValue( ':article_id', $row['article_id'], \PDO::PARAM_INT );
|
||||
$query2 -> bindValue( ':lang_id', $row['lang_id'], \PDO::PARAM_STR );
|
||||
$query2 -> bindValue( ':version', $max_ver, \PDO::PARAM_INT );
|
||||
$query2 -> execute();
|
||||
if ( $query2 -> rowCount() )
|
||||
return true;
|
||||
$query2 -> closeCursor();
|
||||
}
|
||||
$query -> closeCursor();
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function getVersions( $id, $from, $lpk )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'SELECT id , title , version , date_modify FROM pp_articles_langs WHERE article_id = :article_id GROUP BY version ORDER BY version DESC LIMIT ' . $from . ',' . $lpk );
|
||||
$query -> bindValue( ':article_id' , $id , \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
$articles[] = $row;
|
||||
$query -> closeCursor();
|
||||
|
||||
return $articles;
|
||||
}
|
||||
|
||||
public static function getCountVersions( $id )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'SELECT COUNT( DISTINCT( version ) ) FROM pp_articles_langs WHERE article_id = :article_id' );
|
||||
$query -> bindValue( ':article_id' , $id , \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
$row[0];
|
||||
$query -> closeCursor();
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static function getArticleParam( $id )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'SELECT * FROM pp_articles WHERE id = :id' );
|
||||
$query -> bindValue( ':id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
return $row;
|
||||
$query -> closeCursor();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function getPagesAssign( $id = '', $parent_id = 0 )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'SELECT * FROM pp_pages WHERE parent_id = :parent_id ORDER BY id_menu ASC, o ASC' );
|
||||
$query -> bindValue( ':parent_id', $parent_id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
$row['title'] = \admin\factory\Pages::getPageTitle( $row['id'] );
|
||||
|
||||
$query2 = $db -> prepare( 'SELECT page_id FROM pp_articles_pages WHERE article_id = :article_id AND page_id = :page_id' );
|
||||
$query2 -> bindValue( ':article_id', (int)$id, \PDO::PARAM_INT );
|
||||
$query2 -> bindValue( ':page_id', $row['id'], \PDO::PARAM_INT );
|
||||
$query2 -> execute();
|
||||
if ( $query2 -> rowCount() )
|
||||
$row['check'] = 1;
|
||||
else
|
||||
$row['check'] = 0;
|
||||
$query2 -> closeCursor();
|
||||
|
||||
$row['subpages'] = self::getPagesAssign( $id, $row['id'] );
|
||||
|
||||
$pages[] = $row;
|
||||
}
|
||||
$query -> closeCursor();
|
||||
|
||||
return $pages;
|
||||
}
|
||||
|
||||
public static function getArticleParamLanguage( $id = '', $version = '' )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> query( 'SELECT id, name FROM pp_langs WHERE enabled = 1' );
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
if ( $version )
|
||||
{
|
||||
$query2 = $db -> prepare( 'SELECT * FROM pp_articles_langs WHERE article_id = :article_id AND lang_id = :lang_id AND version = :version ORDER BY version DESC LIMIT 1' );
|
||||
$query2 -> bindValue( ':article_id', $id, \PDO::PARAM_INT );
|
||||
$query2 -> bindValue( ':lang_id', $row['id'], \PDO::PARAM_STR );
|
||||
$query2 -> bindValue( ':version', $version, \PDO::PARAM_INT );
|
||||
$query2 -> execute();
|
||||
}
|
||||
else
|
||||
{
|
||||
$query2 = $db -> prepare( 'SELECT * FROM pp_articles_langs WHERE article_id = :article_id AND lang_id = :lang_id ORDER BY version DESC LIMIT 1' );
|
||||
$query2 -> bindValue( ':article_id', $id, \PDO::PARAM_INT );
|
||||
$query2 -> bindValue( ':lang_id', $row['id'], \PDO::PARAM_STR );
|
||||
$query2 -> execute();
|
||||
}
|
||||
|
||||
if ( $query2 -> rowCount() ) while ( $row2 = $query2 -> fetch() )
|
||||
{
|
||||
$lg['title'] = $row2['title'];
|
||||
$lg['meta_description'] = $row2['meta_description'];
|
||||
$lg['meta_keywords'] = $row2['meta_keywords'];
|
||||
$lg['text'] = $row2['text'];
|
||||
$lg['seo_link'] = $row2['seo_link'];
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$lg['title'] = '';
|
||||
$lg['meta_description'] = '';
|
||||
$lg['meta_keywords'] = '';
|
||||
$lg['text'] = '';
|
||||
$lg['seo_link'] = '';
|
||||
}
|
||||
$lg['id'] = $row['id'];
|
||||
$lg['name'] = $row['name'];
|
||||
$language[] = $lg;
|
||||
}
|
||||
return $language;
|
||||
}
|
||||
|
||||
public static function getMaxArticleOrder()
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> query( 'SELECT MAX(o) FROM pp_articles_pages' );
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
return $row[0];
|
||||
$query -> closeCursor();
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static function saveArticle()
|
||||
{
|
||||
global $db;
|
||||
|
||||
\System::deleteCache();
|
||||
\System::deleteCacheAdmin();
|
||||
|
||||
$date = \System::getDate();
|
||||
$pages = \System::formGet( 'pages' );
|
||||
$print = \System::formGetInt( 'print' );
|
||||
$show_date = \System::formGetInt( 'show_date' );
|
||||
$show_title = \System::formGetInt( 'show_title' );
|
||||
$article_id = \System::formGetInt( 'id' );
|
||||
$enabled = \System::formGetInt( 'enabled' );
|
||||
$show_author = \System::formGetInt( 'show_author' );
|
||||
$keep_archive = \System::formGetInt( 'keep_archive' );
|
||||
$layout = \System::formGetInt( 'layout' );
|
||||
$replace_menu = \System::formGetInt( 'replace_menu_title' );
|
||||
$comments_enabled = \System::formGetInt( 'comments_enabled' );
|
||||
|
||||
$sql = 'UPDATE
|
||||
pp_articles
|
||||
SET
|
||||
show_title = :show_title, enabled = :enabled, print = :print, show_date = :show_date, date_modify = :date_modify, show_author = :show_author, keep_archive = :keep_archive,
|
||||
id_layout = :id_layout, replace_menu_title = :replace_menu, comments_enabled = :comments_enabled
|
||||
WHERE
|
||||
id = :id';
|
||||
$query = $db -> prepare( $sql );
|
||||
$query -> bindValue( ':show_title', $show_title, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':enabled', $enabled, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':print', $print, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':show_date', $show_date, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':date_modify', $date, \PDO::PARAM_STR );
|
||||
$query -> bindValue( ':show_author', $show_author, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':keep_archive', $keep_archive, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':id', $article_id, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':id_layout', $layout, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':replace_menu', $replace_menu, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':comments_enabled', $comments_enabled, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
$query -> closeCursor();
|
||||
|
||||
$not_in = '0';
|
||||
if ( is_array( $pages ) ) foreach ( $pages as $pag )
|
||||
{
|
||||
if ( $not_in )
|
||||
$not_in .= ',';
|
||||
$not_in .= $pag;
|
||||
}
|
||||
|
||||
if ( $not_in != '' )
|
||||
{
|
||||
$query = $db -> prepare( 'DELETE FROM pp_articles_pages WHERE article_id = :article_id AND page_id NOT IN (' . $not_in . ')' );
|
||||
$query -> bindValue( ':article_id', $article_id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
$query -> closeCursor();
|
||||
}
|
||||
|
||||
$query = $db -> prepare( 'SELECT page_id FROM pp_articles_pages WHERE article_id = :article_id' );
|
||||
$query -> bindValue( ':article_id', $article_id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
$tab_tmp[] = $row['page_id'];
|
||||
$query -> closeCursor();
|
||||
|
||||
if ( is_array( $pages ) )
|
||||
{
|
||||
$o = self::getMaxArticleOrder() + 1;
|
||||
$query = $db -> prepare( 'INSERT INTO pp_articles_pages ( page_id, article_id, o ) VALUES ( :page_id, :article_id, :o )' );
|
||||
foreach ( $pages as $pag )
|
||||
{
|
||||
if ( !is_array( $tab_tmp ) || !in_array( $pag , $tab_tmp ) )
|
||||
{
|
||||
$query -> bindValue( ':page_id', $pag, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':article_id', $article_id, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':o', $o, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
$o++;
|
||||
}
|
||||
}
|
||||
$query -> closeCursor();
|
||||
}
|
||||
|
||||
if ( $article_id )
|
||||
{
|
||||
$version = self::getMaxArticleVersion( $article_id ) + 1;
|
||||
|
||||
$query = $db -> prepare( 'SELECT id FROM pp_langs WHERE enabled = :enabled' );
|
||||
$query -> bindValue( ':enabled', 1, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
$title = stripslashes( \System::saveString( \System::formGet( 'title_' . $row['id'] ) ) );
|
||||
$meta_description = stripslashes( \System::saveString( \System::formGet( 'meta_description_' . $row['id'] ) ) );
|
||||
$meta_keywords = stripslashes( \System::saveString( \System::formGet( 'meta_keywords_' . $row['id'] ) ) );
|
||||
$text = stripslashes( \System::formGet( 'text_' . $row['id'] ) );
|
||||
$seo_link = \System::formGet( 'seo_link_' . $row['id'] );
|
||||
|
||||
if ( $seo_link == 'link seo' )
|
||||
$seo_link = '';
|
||||
|
||||
if ( $meta_description == 'meta description' )
|
||||
$meta_description = '';
|
||||
|
||||
if ( $meta_keywords == 'meta keywords' )
|
||||
$meta_keywords = '';
|
||||
|
||||
$query2 = $db -> prepare( 'SELECT id, version FROM pp_articles_langs WHERE article_id = :article_id AND lang_id = :lang_id ORDER BY version DESC LIMIT 1' );
|
||||
$query2 -> bindValue( ':article_id', $article_id, \PDO::PARAM_INT );
|
||||
$query2 -> bindValue( ':lang_id', $row['id'], \PDO::PARAM_STR );
|
||||
$query2 -> execute();
|
||||
if ( $query2 -> rowCount() && !$keep_archive )
|
||||
{
|
||||
while ( $row2 = $query2 -> fetch() )
|
||||
{
|
||||
$query3 = $db -> prepare( 'UPDATE pp_articles_langs SET text = :text, meta_description = :meta_description, meta_keywords = :meta_keywords, title = :title, seo_link = :seo_link WHERE article_id = :article_id AND lang_id = :lang_id AND version = :version' );
|
||||
$query3 -> bindValue( ':text', $text, \PDO::PARAM_STR );
|
||||
$query3 -> bindValue( ':meta_description', $meta_description, \PDO::PARAM_STR );
|
||||
$query3 -> bindValue( ':meta_keywords', $meta_keywords, \PDO::PARAM_STR );
|
||||
$query3 -> bindValue( ':title', $title, \PDO::PARAM_STR );
|
||||
$query3 -> bindValue( ':article_id', $article_id, \PDO::PARAM_INT );
|
||||
$query3 -> bindValue( ':lang_id', $row['id'], \PDO::PARAM_STR );
|
||||
$query3 -> bindValue( ':version', $row2['version'], \PDO::PARAM_INT );
|
||||
$query3 -> bindValue( ':seo_link', $seo_link, \PDO::PARAM_STR );
|
||||
$query3 -> execute();
|
||||
$query3 -> closeCursor();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$query3 = $db -> prepare( 'INSERT INTO pp_articles_langs ( text, meta_description, meta_keywords, title, article_id, lang_id, version, seo_link ) VALUES ( :text, :meta_description, :meta_keywords, :title, :article_id, :lang_id, :version, :seo_link )' );
|
||||
$query3 -> bindValue( ':text', $text, \PDO::PARAM_STR );
|
||||
$query3 -> bindValue( ':meta_description', $meta_description, \PDO::PARAM_STR );
|
||||
$query3 -> bindValue( ':meta_keywords', $meta_keywords, \PDO::PARAM_STR );
|
||||
$query3 -> bindValue( ':title', $title, \PDO::PARAM_STR );
|
||||
$query3 -> bindValue( ':article_id', $article_id, \PDO::PARAM_INT );
|
||||
$query3 -> bindValue( ':lang_id', $row['id'], \PDO::PARAM_STR );
|
||||
$query3 -> bindValue( ':version', $version, \PDO::PARAM_INT );
|
||||
$query3 -> bindValue( ':seo_link', $seo_link, \PDO::PARAM_STR );
|
||||
$query3 -> execute();
|
||||
$query3 -> closeCursor();
|
||||
}
|
||||
}
|
||||
}
|
||||
\System::rewriteHtacces();
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function addArticle()
|
||||
{
|
||||
global $user, $db;
|
||||
|
||||
\System::deleteCache();
|
||||
\System::deleteCacheAdmin();
|
||||
|
||||
$date = \System::getDate();
|
||||
$pages = \System::formGet( 'pages' );
|
||||
$enabled = \System::formGetInt( 'enabled' );
|
||||
$print = \System::formGetInt( 'print' );
|
||||
$show_date = \System::formGetInt( 'show_date' );
|
||||
$show_title = \System::formGetInt( 'show_title' );
|
||||
$show_author = \System::formGetInt( 'show_author' );
|
||||
$keep_archive = \System::formGetInt( 'keep_archive' );
|
||||
$layout = \System::formGetInt( 'layout' );
|
||||
$replace_menu = \System::formGetInt( 'replace_menu_title' );
|
||||
$comments_enabled = \System::formGetInt( 'comments_enabled' );
|
||||
|
||||
if ( \System::getSessionVar( 'check' ) == \System::formGet( 'check' ) )
|
||||
return false;
|
||||
|
||||
\System::setSessionVar( 'check', \System::formGet( 'check' ) );
|
||||
|
||||
$sql = 'INSERT INTO
|
||||
pp_articles
|
||||
( show_title , enabled , print , show_date , date_add , date_modify , show_author , author , keep_archive, id_layout, replace_menu_title, comments_enabled )
|
||||
VALUES
|
||||
( :show_title , :enabled , :print , :show_date , :date_add , :date_modify , :show_author , :author , :keep_archive, :id_layout, :replace_menu, :comments_enabled )';
|
||||
$query = $db -> prepare( $sql );
|
||||
$query -> bindValue( ':show_title', $show_title, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':enabled', $enabled, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':print', $print, \PDO::PARAM_STR );
|
||||
$query -> bindValue( ':show_date', $show_date, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':date_add', $date, \PDO::PARAM_STR );
|
||||
$query -> bindValue( ':date_modify', $date, \PDO::PARAM_STR );
|
||||
$query -> bindValue( ':show_author', $show_author, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':author', $user -> _values['id'], \PDO::PARAM_STR );
|
||||
$query -> bindValue( ':keep_archive', $keep_archive, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':id_layout', $layout, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':replace_menu', $replace_menu, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':comments_enabled', $comments_enabled, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
$query -> closeCursor();
|
||||
|
||||
$article_id = $db -> lastInsertId();
|
||||
|
||||
if ( $article_id )
|
||||
{
|
||||
if ( is_array( $pages ) )
|
||||
{
|
||||
$o = self::getMaxArticleOrder() + 1;
|
||||
$query = $db -> prepare( 'INSERT INTO pp_articles_pages ( page_id, article_id, o ) VALUES ( :page_id, :article_id, :o )' );
|
||||
foreach ( $pages as $page )
|
||||
{
|
||||
$query -> bindValue( ':page_id', $page, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':article_id', $article_id, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':o', $o, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
$o++;
|
||||
}
|
||||
$query -> closeCursor();
|
||||
}
|
||||
|
||||
$query = $db -> prepare( 'SELECT id FROM pp_langs WHERE enabled = :enabled' );
|
||||
$query -> bindValue( ':enabled', 1, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
$title = \System::saveString( \System::formGet( 'title_' . $row['id'] ) );
|
||||
$meta_description = \System::saveString( \System::formGet( 'meta_description_' . $row['id'] ) );
|
||||
$meta_keywords = \System::saveString( \System::formGet( 'meta_keywords_' . $row['id'] ) );
|
||||
$text = stripslashes( \System::formGet( 'text_' . $row['id'] ) );
|
||||
$seo_link = \System::formGet( 'seo_link_' . $row['id'] );
|
||||
|
||||
if ( $seo_link == 'link seo' )
|
||||
$seo_link = '';
|
||||
|
||||
if ( $meta_description == 'meta description' )
|
||||
$meta_description = '';
|
||||
|
||||
if ( $meta_keywords == 'meta keywords' )
|
||||
$meta_keywords = '';
|
||||
|
||||
$sql = 'INSERT INTO
|
||||
pp_articles_langs
|
||||
( article_id, lang_id, text, meta_description, meta_keywords, title, version, seo_link )
|
||||
VALUES
|
||||
( :article_id, :lang_id, :text, :meta_description, :meta_keywords, :title, :version, :seo_link )';
|
||||
$query2 = $db -> prepare( $sql );
|
||||
$query2 -> bindValue( ':article_id', $article_id, \PDO::PARAM_INT );
|
||||
$query2 -> bindValue( ':lang_id', $row['id'], \PDO::PARAM_STR );
|
||||
$query2 -> bindValue( ':text', $text, \PDO::PARAM_STR );
|
||||
$query2 -> bindValue( ':meta_description', $meta_description, \PDO::PARAM_STR );
|
||||
$query2 -> bindValue( ':meta_keywords', $meta_keywords, \PDO::PARAM_STR );
|
||||
$query2 -> bindValue( ':title', $title, \PDO::PARAM_STR );
|
||||
$query2 -> bindValue( ':version', 0, \PDO::PARAM_INT );
|
||||
$query2 -> bindValue( ':seo_link', $seo_link, \PDO::PARAM_STR );
|
||||
$query2 -> execute();
|
||||
$query2 -> closeCursor();
|
||||
}
|
||||
\System::rewriteHtacces();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function setAsArchive( $id )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'UPDATE pp_articles SET archive = :archive WHERE id = :id' );
|
||||
$query -> bindValue( ':id' , $id , \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':archive' , 1 , \PDO::PARAM_STR );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() )
|
||||
{
|
||||
\System::rewriteHtacces();
|
||||
\System::deleteCache();
|
||||
\System::deleteCacheAdmin();
|
||||
return true;
|
||||
}
|
||||
$query -> closeCursor();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
?>
|
||||
230
autoload/admin/factory/class.Banners.php
Normal file
230
autoload/admin/factory/class.Banners.php
Normal file
@@ -0,0 +1,230 @@
|
||||
<?
|
||||
namespace admin\factory;
|
||||
|
||||
class Banners
|
||||
{
|
||||
public static function getBannersAll()
|
||||
{
|
||||
global $db, $cache, $config;
|
||||
|
||||
$key = 'getBannersAll';
|
||||
|
||||
if ( !$banners = $cache -> fetch( $key ) )
|
||||
{
|
||||
$query = $db -> prepare('SELECT title, link, image FROM pp_banner WHERE enabled = :enabled ORDER BY o');
|
||||
$query -> bindValue(':enabled', 1, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
$banners[] = $row;
|
||||
$query -> closeCursor();
|
||||
$cache -> store( $key, $banners, $config['cache_expire'] );
|
||||
}
|
||||
|
||||
return $banners;
|
||||
}
|
||||
|
||||
public static function getCountBanners()
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'SELECT count(id) FROM pp_banner' );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
return $row[0];
|
||||
}
|
||||
|
||||
public static function getBanners( $from, $lpk )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$lp = 1;
|
||||
$tab = \System::getComboYesNo();
|
||||
$banners = '';
|
||||
|
||||
$query = $db -> prepare( 'SELECT title, link, enabled, id, o FROM pp_banner ORDER BY o ASC LIMIT ' . $from . ',' . $lpk );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
$ban['title'] = $row['title'];
|
||||
$ban['link'] = $row['link'];
|
||||
$ban['lp'] = $lp;
|
||||
$ban['enabled'] = $tab[$row['enabled']];
|
||||
$ban['id'] = $row['id'];
|
||||
|
||||
$query2 = $db -> prepare( 'SELECT id FROM pp_banner WHERE o > :o ORDER BY o ASC LIMIT 1' );
|
||||
$query2 -> bindValue( ':o', $row['o'], \PDO::PARAM_INT );
|
||||
$query2 -> execute();
|
||||
if ( $query2 -> rowCount() ) while ( $row2 = $query2 -> fetch() )
|
||||
$ban['down'] = true;
|
||||
else
|
||||
$ban['down'] = false;
|
||||
$query2 -> closeCursor();
|
||||
|
||||
$query2 = $db -> prepare( 'SELECT id FROM pp_banner WHERE o < :o ORDER BY o ASC LIMIT 1' );
|
||||
$query2 -> bindValue( ':o', $row['o'], \PDO::PARAM_INT );
|
||||
$query2 -> execute();
|
||||
if ( $query2 -> rowCount() ) while ( $row2 = $query2 -> fetch() )
|
||||
$ban['up'] = true;
|
||||
else
|
||||
$ban['up'] = false;
|
||||
$query2 -> closeCursor();
|
||||
|
||||
$akcja = "function mycallbackform(v,m,f){
|
||||
if( v == true )
|
||||
document.location.href='index.php?rw=del&id=" . $row['id'] . "';
|
||||
}";
|
||||
$akcja .= "$.prompt( 'Na pewno chcesz usunąć wybrany baner?',{ callback: mycallbackform, buttons: { tak: true, nie: false }, focus: 1 })";
|
||||
$akcja = 'onClick="'.$akcja.'"';
|
||||
$ban['action'] = $akcja;
|
||||
$banners[] = $ban;
|
||||
$lp++;
|
||||
}
|
||||
$query -> closeCursor();
|
||||
|
||||
return $banners;
|
||||
}
|
||||
|
||||
public static function getMaxOrder()
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'SELECT MAX(o) FROM pp_banner' );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
return $row[0]+1;
|
||||
}
|
||||
|
||||
public static function moveBannerDown( $id )
|
||||
{
|
||||
global $db;
|
||||
|
||||
try
|
||||
{
|
||||
$db -> beginTransaction();
|
||||
|
||||
$query = $db -> prepare( 'SELECT o FROM pp_banner WHERE id = :id' );
|
||||
$query -> bindValue( ':id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
$o1 = $row['o'];
|
||||
$query -> closeCursor();
|
||||
|
||||
$query = $db -> prepare( 'SELECT id, o FROM pp_banner WHERE o > :order ORDER BY o ASC LIMIT 1' );
|
||||
$query -> bindValue( ':order', $o1, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
$query2 = $db -> prepare( 'UPDATE pp_banner SET o = :order WHERE id = :id' );
|
||||
$query2 -> bindValue( ':order', $row['o'], \PDO::PARAM_INT );
|
||||
$query2 -> bindValue( ':id', $id, \PDO::PARAM_INT );
|
||||
$query2 -> execute();
|
||||
$query2 -> closeCursor();
|
||||
|
||||
$query2 = $db -> prepare( 'UPDATE pp_banner SET o = :order WHERE id = :id' );
|
||||
$query2 -> bindValue( ':order', $o1, \PDO::PARAM_INT );
|
||||
$query2 -> bindValue( ':id', $row['id'], \PDO::PARAM_INT );
|
||||
$query2 -> execute();
|
||||
$query2 -> closeCursor();
|
||||
}
|
||||
$query -> closeCursor();
|
||||
|
||||
$db -> commit();
|
||||
|
||||
\System::deleteCacheAdmin();
|
||||
\System::deleteCache();
|
||||
return true;
|
||||
}
|
||||
catch ( \PDOException $ex )
|
||||
{
|
||||
$db -> rollBack();
|
||||
\System::setAlert( 'Błąd: ' . $ex -> getMessage() );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function moveBannerUp( $id )
|
||||
{
|
||||
global $db;
|
||||
|
||||
try
|
||||
{
|
||||
$db -> beginTransaction();
|
||||
|
||||
$query = $db -> prepare( 'SELECT o FROM pp_banner WHERE id = :id' );
|
||||
$query -> bindValue( ':id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
$o1 = $row['o'];
|
||||
$query -> closeCursor();
|
||||
|
||||
$query = $db -> prepare( 'SELECT id, o FROM pp_banner WHERE o < :order ORDER BY o DESC LIMIT 1' );
|
||||
$query -> bindValue( ':order', $o1, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
$query2 = $db -> prepare( 'UPDATE pp_banner SET o = :order WHERE id = :id' );
|
||||
$query2 -> bindValue( ':order', $row['o'], \PDO::PARAM_INT );
|
||||
$query2 -> bindValue( ':id', $id, \PDO::PARAM_INT );
|
||||
$query2 -> execute();
|
||||
$query2 -> closeCursor();
|
||||
|
||||
$query2 = $db -> prepare( 'UPDATE pp_banner SET o = :order WHERE id = :id' );
|
||||
$query2 -> bindValue( ':order', $o1, \PDO::PARAM_INT );
|
||||
$query2 -> bindValue( ':id', $row['id'], \PDO::PARAM_INT );
|
||||
$query2 -> execute();
|
||||
$query2 -> closeCursor();
|
||||
}
|
||||
$query -> closeCursor();
|
||||
|
||||
$db -> commit();
|
||||
|
||||
\System::deleteCacheAdmin();
|
||||
\System::deleteCache();
|
||||
return true;
|
||||
}
|
||||
catch ( \PDOException $ex )
|
||||
{
|
||||
$db -> rollBack();
|
||||
\System::setAlert( 'Błąd: ' . $ex -> getMessage() );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function deleteBanner( $id )
|
||||
{
|
||||
global $db;
|
||||
|
||||
try
|
||||
{
|
||||
$db -> beginTransaction();
|
||||
|
||||
$query = $db -> prepare( 'SELECT image FROM pp_banner WHERE id = :id' );
|
||||
$query -> bindValue( ':id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
if ( file_exists( "../" . $row['image'] ) && $row['image'] )
|
||||
unlink("../" . $row['image']);
|
||||
|
||||
$query2 = $db -> prepare( 'DELETE FROM pp_banner WHERE id = :id' );
|
||||
$query2 -> bindValue( ':id', $id, \PDO::PARAM_INT );
|
||||
$query2 -> execute();
|
||||
$query2 -> closeCursor();
|
||||
}
|
||||
$query -> closeCursor();
|
||||
|
||||
$db -> commit();
|
||||
|
||||
\System::deleteCacheAdmin();
|
||||
\System::deleteCache();
|
||||
return true;
|
||||
}
|
||||
catch ( \PDOException $ex )
|
||||
{
|
||||
$db -> rollBack();
|
||||
\System::setAlert( 'Błąd: ' . $ex -> getMessage() );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
?>
|
||||
19
autoload/admin/factory/class.GuestBook.php
Normal file
19
autoload/admin/factory/class.GuestBook.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?
|
||||
namespace admin\factory;
|
||||
|
||||
class GuestBook
|
||||
{
|
||||
public function deleteEntry( $id )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'DELETE FROM pp_guest_book WHERE id = :id' );
|
||||
$query -> bindValue( ':id' , $id , \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() )
|
||||
return true;
|
||||
$query -> closeCursor();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
?>
|
||||
20
autoload/admin/factory/class.Languages.php
Normal file
20
autoload/admin/factory/class.Languages.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?
|
||||
// po poprawkach
|
||||
namespace admin\factory;
|
||||
|
||||
class Languages
|
||||
{
|
||||
public function deleteTranslation( $id )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'DELETE FROM pp_langs_text WHERE id = :id' );
|
||||
$query -> bindValue( ':id' , $id , \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() )
|
||||
return true;
|
||||
$query -> closeCursor();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
?>
|
||||
254
autoload/admin/factory/class.Layouts.php
Normal file
254
autoload/admin/factory/class.Layouts.php
Normal file
@@ -0,0 +1,254 @@
|
||||
<?php
|
||||
// po poprawkach
|
||||
namespace admin\factory;
|
||||
|
||||
class Layouts {
|
||||
|
||||
public static function getLayouts()
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> query( 'SELECT id, name FROM pp_layouts' );
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
$layouts[] = $row;
|
||||
$query -> closeCursor();
|
||||
|
||||
return $layouts;
|
||||
}
|
||||
|
||||
public static function getLayout( $id, $admin = false )
|
||||
{
|
||||
global $db, $config, $cache;
|
||||
|
||||
$key = 'getLayout:' . $id;
|
||||
if ( $admin || !$layout = $cache -> fetch( $key ) )
|
||||
{
|
||||
$query = $db -> prepare( 'SELECT * FROM pp_layouts WHERE id = :id' );
|
||||
$query -> bindValue( ':id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
$layout = $row;
|
||||
$query -> closeCursor();
|
||||
$cache -> store( $key, $layout, $config['cache_expire_long'] );
|
||||
}
|
||||
return $layout;
|
||||
}
|
||||
|
||||
public static function getActiveLayout()
|
||||
{
|
||||
global $db , $site, $cache, $config;
|
||||
|
||||
$key = 'getActiveLayout:' . $site -> _values['id'];
|
||||
|
||||
if ( !$layout = $cache -> fetch( $key ) )
|
||||
{
|
||||
$query = $db -> prepare( 'SELECT * FROM pp_layouts_pages, pp_layouts WHERE page_id = :page_id AND pp_layouts.id = layout_id ORDER BY layout_id DESC LIMIT 1' );
|
||||
$query -> bindValue( ':page_id', $site -> _values['id'], \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
$layout = $row;
|
||||
$query -> closeCursor();
|
||||
|
||||
if ( !$layout )
|
||||
{
|
||||
$query = $db -> prepare( 'SELECT html , css , javascript FROM pp_layouts WHERE enabled = :enabled' );
|
||||
$query -> bindValue( ':enabled', 1, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
$layout = $row;
|
||||
$query -> closeCursor();
|
||||
}
|
||||
$cache -> store( $key, $layout, $config['cache_expire'] );
|
||||
}
|
||||
|
||||
return $layout;
|
||||
}
|
||||
|
||||
public static function getSelectedPages( $id )
|
||||
{
|
||||
global $db, $config, $cache;
|
||||
|
||||
$key = 'getSelectedPages:' . $id;
|
||||
|
||||
if ( !$pages = $cache -> fetch( $key ) )
|
||||
{
|
||||
$query = $db -> prepare( 'SELECT page_id FROM pp_layouts_pages WHERE layout_id = :layout_id' );
|
||||
$query -> bindValue( ':layout_id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
$pages[] = $row['page_id'];
|
||||
$query -> closeCursor();
|
||||
$cache -> store( $key , $pages , $config['cache_expire'] );
|
||||
}
|
||||
return $pages;
|
||||
}
|
||||
|
||||
public static function getPagesAssign( $id = '', $parent_id = 0 )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'SELECT * FROM pp_pages WHERE parent_id = :parent_id ORDER BY id_menu ASC, o ASC' );
|
||||
$query -> bindValue( ':parent_id', $parent_id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
$row['title'] = \admin\factory\Pages::getPageTitle( $row['id'] );
|
||||
$row['check'] = 0;
|
||||
|
||||
if ( $id )
|
||||
{
|
||||
$query2 = $db -> prepare( 'SELECT page_id FROM pp_layouts_pages WHERE layout_id = :layout_id AND page_id = :page_id' );
|
||||
$query2 -> bindValue( ':layout_id', $id, \PDO::PARAM_INT );
|
||||
$query2 -> bindValue( ':page_id', $row['id'], \PDO::PARAM_INT );
|
||||
$query2 -> execute();
|
||||
if ( $query2 -> rowCount() )
|
||||
$row['check'] = 1;
|
||||
$query2 -> closeCursor();
|
||||
}
|
||||
|
||||
$row['subpages'] = self::getPagesAssign( $id, $row['id'] );
|
||||
|
||||
$pages[] = $row;
|
||||
}
|
||||
$query -> closeCursor();
|
||||
|
||||
return $pages;
|
||||
}
|
||||
|
||||
public static function addLayout()
|
||||
{
|
||||
global $db;
|
||||
|
||||
$name = \System::formGet( 'name' );
|
||||
$enabled = \System::formGet( 'enabled' );
|
||||
$html = \System::formGet( 'html' );
|
||||
$css = \System::formGet( 'css' );
|
||||
$js = \System::formGet( 'js' );
|
||||
$pages = \System::formGet( 'pages' );
|
||||
|
||||
if ( $enabled == 1 )
|
||||
{
|
||||
$query = $db -> prepare( 'UPDATE pp_layouts SET enabled = :enabled' );
|
||||
$query -> bindValue( ':enabled', 0, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
$query -> closeCursor();
|
||||
}
|
||||
|
||||
$query = $db -> prepare( 'INSERT INTO pp_layouts ( name , enabled , html , css , javascript ) VALUES ( :name , :enabled , :html , :css , :javascript )' );
|
||||
$query -> bindValue( ':name', $name, \PDO::PARAM_STR );
|
||||
$query -> bindValue( ':enabled', $enabled, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':html', $html, \PDO::PARAM_STR );
|
||||
$query -> bindValue( ':css', $css, \PDO::PARAM_STR );
|
||||
$query -> bindValue( ':javascript', $js, \PDO::PARAM_STR );
|
||||
$query -> execute();
|
||||
$query -> closeCursor();
|
||||
|
||||
$id = $db -> lastInsertId();
|
||||
|
||||
if ( is_array( $pages ) ) foreach ( $pages as $page )
|
||||
{
|
||||
$query = $db -> prepare( 'INSERT INTO pp_layouts_pages ( layout_id , page_id ) VALUES ( :layout_id , :page_id )' );
|
||||
$query -> bindValue( ':layout_id', $id, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':page_id', $page, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
$query -> closeCursor();
|
||||
}
|
||||
|
||||
\System::deleteCacheAdmin();
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function saveLayout()
|
||||
{
|
||||
global $db;
|
||||
|
||||
$id = \System::formGetInt( 'id' );
|
||||
$name = \System::formGet( 'name' );
|
||||
$enabled = \System::formGet( 'enabled' );
|
||||
$html = \System::formGet( 'html' );
|
||||
$css = \System::formGet( 'css' );
|
||||
$js = \System::formGet( 'js' );
|
||||
$pages = \System::formGet( 'pages' );
|
||||
|
||||
if ( $enabled )
|
||||
{
|
||||
$query = $db -> prepare( 'UPDATE pp_layouts SET enabled = :enabled' );
|
||||
$query -> bindValue( ':enabled', 0, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
$query -> closeCursor();
|
||||
}
|
||||
$html = addslashes( $html );
|
||||
|
||||
$query = $db -> prepare( 'UPDATE pp_layouts SET name = :name , enabled = :enabled , html = :html , css = :css , javascript = :javascript WHERE id = :id' );
|
||||
$query -> bindValue( ':name', $name, \PDO::PARAM_STR );
|
||||
$query -> bindValue( ':enabled', $enabled, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':html', $html, \PDO::PARAM_STR );
|
||||
$query -> bindValue( ':css', $css, \PDO::PARAM_STR );
|
||||
$query -> bindValue( ':javascript', $js, \PDO::PARAM_STR );
|
||||
$query -> bindValue( ':id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
$query -> closeCursor();
|
||||
|
||||
$query = $db -> prepare( 'DELETE FROM pp_layouts_pages WHERE layout_id = :layout_id' );
|
||||
$query -> bindValue( ':layout_id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
$query -> closeCursor();
|
||||
|
||||
if ( is_array( $pages ) ) foreach ( $pages as $page )
|
||||
{
|
||||
$query = $db -> prepare( 'INSERT INTO pp_layouts_pages ( layout_id , page_id ) VALUES ( :layout_id , :page_id )' );
|
||||
$query -> bindValue( ':layout_id', $id, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':page_id', $page, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
$query -> closeCursor();
|
||||
}
|
||||
|
||||
\System::deleteCache();
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function deleteLayout( $id )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'SELECT count(id) FROM pp_layouts' );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
if ( $row[0] <= 1 )
|
||||
return false;
|
||||
}
|
||||
$query -> closeCursor();
|
||||
|
||||
$query = $db -> prepare( 'DELETE FROM pp_layouts_pages WHERE layout_id = :layout_id' );
|
||||
$query -> bindValue( ':layout_id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
$query -> closeCursor();
|
||||
|
||||
$query = $db -> prepare( 'SELECT count(id) FROM pp_layouts WHERE enabled = :enabled' );
|
||||
$query -> bindValue( ':enabled', 1, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
if ( $row[0] == 0 )
|
||||
{
|
||||
$query2 = $db -> prepare( 'UPDATE pp_layouts SET enabled = :enabled LIMIT 1' );
|
||||
$query2 -> bindValue( ':enabled', 1, \PDO::PARAM_INT );
|
||||
$query2 -> execute();
|
||||
$query2 -> closeCursor();
|
||||
}
|
||||
}
|
||||
$query -> closeCursor();
|
||||
|
||||
$query = $db -> prepare( 'DELETE FROM pp_layouts WHERE id = :id' );
|
||||
$query -> bindValue( ':id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() )
|
||||
{
|
||||
\System::deleteCache();
|
||||
return true;
|
||||
}
|
||||
$query -> closeCursor();
|
||||
}
|
||||
}
|
||||
?>
|
||||
65
autoload/admin/factory/class.Menu.php
Normal file
65
autoload/admin/factory/class.Menu.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
// po poprawkach
|
||||
namespace admin\factory;
|
||||
|
||||
class Menu
|
||||
{
|
||||
public static function getMenuType()
|
||||
{
|
||||
return array( 0 => 'menu poziome', 1 => 'menu pionowe' );
|
||||
}
|
||||
|
||||
public static function getMenu()
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'SELECT * FROM pp_menu ORDER BY id ASC' );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
$Menu[] = $row;
|
||||
$query -> closeCursor();
|
||||
return $Menu;
|
||||
}
|
||||
|
||||
public static function getMenuName( $id )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'SELECT name FROM pp_menu WHERE id = :id' );
|
||||
$query -> bindValue( ':id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
return $row['name'];
|
||||
$query -> closeCursor();
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function deleteMenu( $id )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$flag = true;
|
||||
|
||||
$query = $db -> prepare( 'SELECT count(id) FROM pp_pages WHERE id_menu=:id_menu' );
|
||||
$query -> bindValue( ':id_menu', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
if ( $row[0] > 0 )
|
||||
$flag = false;
|
||||
}
|
||||
$query -> closeCursor();
|
||||
|
||||
if ( $flag )
|
||||
{
|
||||
$query = $db -> prepare( 'DELETE FROM pp_menu WHERE id = :id' );
|
||||
$query -> bindValue( ':id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
$query -> closeCursor();
|
||||
\System::setAlert( 'Menu został usunięte.' );
|
||||
}
|
||||
else
|
||||
\System::setAlert( 'Nie można usunąć wybranego menu z powodu przypisanych podstron.' );
|
||||
}
|
||||
}
|
||||
?>
|
||||
18
autoload/admin/factory/class.Newsletter.php
Normal file
18
autoload/admin/factory/class.Newsletter.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
namespace admin\factory;
|
||||
|
||||
class Newsletter {
|
||||
|
||||
public function deleteEmail( $id )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'DELETE FROM pp_newsletter_emails WHERE id = :id' );
|
||||
$query -> bindValue( ':id' , $id , \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() )
|
||||
return true;
|
||||
$query -> closeCursor();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
419
autoload/admin/factory/class.Pages.php
Normal file
419
autoload/admin/factory/class.Pages.php
Normal file
@@ -0,0 +1,419 @@
|
||||
<?
|
||||
// po poprawkach
|
||||
namespace admin\factory;
|
||||
|
||||
class Pages
|
||||
{
|
||||
public static function getPageLayout( $id )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'SELECT layout_id FROM pp_layouts_pages WHERE page_id = :page_id' );
|
||||
$query -> bindValue( ':page_id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
return $row['layout_id'];
|
||||
$query -> closeCursor();
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function getSortTypes()
|
||||
{
|
||||
global $db;
|
||||
|
||||
$sort = array();
|
||||
|
||||
$query = $db -> prepare( 'SELECT id , name FROM pp_page_sorts ORDER BY name ASC' );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
$st['id'] = $row['id'];
|
||||
$st['name'] = $row['name'];
|
||||
$sort[] = $st;
|
||||
}
|
||||
$query -> closeCursor();
|
||||
|
||||
return $sort;
|
||||
}
|
||||
|
||||
public static function getPageTypes()
|
||||
{
|
||||
global $db;
|
||||
|
||||
$pages = array();
|
||||
|
||||
$query = $db -> prepare( 'SELECT id , name FROM pp_page_types WHERE enabled = :enabled ORDER BY name ASC' );
|
||||
$query -> bindValue( ':enabled', 1, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
$pg['id'] = $row['id'];
|
||||
$pg['name'] = $row['name'];
|
||||
$pages[] = $pg;
|
||||
}
|
||||
$query -> closeCursor();
|
||||
|
||||
return $pages;
|
||||
}
|
||||
|
||||
public static function getAssignedArticles( $id )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'SELECT article_id FROM pp_articles_pages WHERE page_id = :page_id ORDER BY o DESC' );
|
||||
$query -> bindValue( ':page_id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
$articles[] = \article\FArticle::loadArticle( $row['article_id'] );
|
||||
$query -> closeCursor();
|
||||
|
||||
return $articles;
|
||||
}
|
||||
|
||||
public static function getPageParam( $id )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'SELECT * FROM pp_pages WHERE id = :id' );
|
||||
$query -> bindValue( ':id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
return $row;
|
||||
}
|
||||
|
||||
public static function getPageParamLanguage( $id )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'SELECT id, name FROM pp_langs WHERE enabled = :enabled' );
|
||||
$query -> bindValue( ':enabled', 1, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
$lg = '';
|
||||
|
||||
$query2 = $db -> prepare( 'SELECT * FROM pp_pages_langs WHERE page_id = :page_id AND lang_id = :lang_id' );
|
||||
$query2 -> bindValue( ':page_id', $id, \PDO::PARAM_INT );
|
||||
$query2 -> bindValue( ':lang_id', $row['id'], \PDO::PARAM_STR );
|
||||
$query2 -> execute();
|
||||
if ( $query2 -> rowCount() ) while ( $row2 = $query2 -> fetch() )
|
||||
$lg = $row2;
|
||||
$query2 -> closeCursor();
|
||||
|
||||
$lg['id'] = $row['id'];
|
||||
$lg['name'] = $row['name'];
|
||||
$language[] = $lg;
|
||||
}
|
||||
$query -> closeCursor();
|
||||
|
||||
return $language;
|
||||
}
|
||||
|
||||
public static function getPageTitle( $id, $language = 'pl' )
|
||||
{
|
||||
global $db, $cache, $config;
|
||||
|
||||
$key = 'pageTitle:' . $id . ':' . $language;
|
||||
|
||||
if ( !$title = $cache -> fetch( $key ) )
|
||||
{
|
||||
$query = $db -> prepare( 'SELECT title FROM pp_pages_langs WHERE page_id = :page_id AND lang_id = :lang_id' );
|
||||
$query -> bindValue( ':page_id', $id, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':lang_id', $language, \PDO::PARAM_STR );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
$title = $row['title'];
|
||||
$query -> closeCursor();
|
||||
$cache -> store( $key , $title , $config['cache_expire_long' ] );
|
||||
}
|
||||
if ( $title == '' )
|
||||
{
|
||||
$key = 'pageTitle:' . $id;
|
||||
if ( !$title = $cache -> fetch( $key ) )
|
||||
{
|
||||
$query = $db -> prepare( 'SELECT title FROM pp_pages_langs WHERE page_id = :page_id AND title != "" LIMIT 1' );
|
||||
$query -> bindValue( ':page_id', $id, \PDO::PARAM_STR );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
$title = $row['title'];
|
||||
$query -> closeCursor();
|
||||
$cache -> store( $key , $title , $config['cache_expire_long' ] );
|
||||
}
|
||||
}
|
||||
|
||||
return $title;
|
||||
}
|
||||
|
||||
public static function getPages( $menu_id = 1, $parent_id = 0 )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'SELECT id, id_menu, enabled FROM pp_pages WHERE id_menu = :id_menu AND parent_id = :parent_id ORDER BY o ASC' );
|
||||
$query -> bindValue( ':parent_id', $parent_id, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':id_menu', $menu_id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
$row['title'] = self::getPageTitle( $row['id'] );
|
||||
$row['subpages'] = self::getPages( $menu_id, $row['id'] );
|
||||
$pages[] = $row;
|
||||
}
|
||||
|
||||
return $pages;
|
||||
}
|
||||
|
||||
public static function selectMaxOrder()
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'SELECT MAX(o) FROM pp_pages' );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
$order = $row[0]+1;
|
||||
$query -> closeCursor();
|
||||
|
||||
return $order;
|
||||
}
|
||||
|
||||
public static function savePage()
|
||||
{
|
||||
global $db;
|
||||
|
||||
\System::deleteCacheAdmin();
|
||||
\System::deleteCache();
|
||||
|
||||
$enabled = \System::formGet( 'enabled' );
|
||||
$show_title = \System::formGet( 'show_title' );
|
||||
$sort_type = \System::formGet( 'sort_type' );
|
||||
$page_type_id = \System::formGet( 'page_type_id' );
|
||||
$link = \System::formGet( 'link' );
|
||||
$page_id = \System::formGetInt( 'id' );
|
||||
$article_number = \System::formGetInt( 'article_number' );
|
||||
$parent_id = \System::formGetInt( 'parent_id' );
|
||||
$only_for_logged = \System::formGetInt( 'only_for_logged' );
|
||||
$menu = \System::formGetInt( 'menu_id' );
|
||||
$contact_form = \System::formGetInt( 'contact_form' );
|
||||
$layout_id = \System::formGetInt( 'layout_id' );
|
||||
|
||||
$query = $db -> prepare( 'UPDATE pp_pages SET contact_form = :contact_form, only_for_logged = :only_for_logged, link = :link, id_menu = :id_menu, id_page_type = :id_page_type, id_sort_type = :id_sort_type, article_number = :article_number, show_title = :show_title, enabled = :enabled, parent_id = :parent_id WHERE id = :id ' );
|
||||
$query -> bindValue( ':only_for_logged', $only_for_logged, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':id_menu', $menu, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':id_page_type', $page_type_id, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':id_sort_type', $sort_type, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':article_number', $article_number, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':show_title', $show_title, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':enabled', $enabled, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':id', $page_id, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':parent_id', $parent_id, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':link', $link, \PDO::PARAM_STR );
|
||||
$query -> bindValue( ':contact_form', $contact_form, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
$query -> closeCursor();
|
||||
|
||||
if ( $page_id )
|
||||
{
|
||||
$query = $db -> prepare( 'DELETE FROM pp_layouts_pages WHERE page_id = :page_id' );
|
||||
$query -> bindValue( ':page_id', $page_id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
$query -> closeCursor();
|
||||
|
||||
$query = $db -> prepare( 'INSERT INTO pp_layouts_pages ( layout_id, page_id ) VALUES ( :layout_id, :page_id )' );
|
||||
$query -> bindValue( ':layout_id', $layout_id, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':page_id', $page_id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
$query -> closeCursor();
|
||||
|
||||
$query = $db -> prepare( 'SELECT id FROM pp_langs WHERE enabled = :enabled' );
|
||||
$query -> bindValue( ':enabled', 1, \PDO::PARAM_STR );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
$title = \System::formGet( 'title_' . $row['id'] );
|
||||
$meta_description = \System::formGet( 'meta_description_' . $row['id'] );
|
||||
$meta_keywords = \System::formGet( 'meta_keywords_' . $row['id'] );
|
||||
$meta_title = \System::formGet( 'meta_title_' . $row['id'] );
|
||||
$seo_link = \System::seo( \System::formGet( 'seo_link_' . $row['id'] ) );
|
||||
|
||||
if ( $title )
|
||||
{
|
||||
$query2 = $db -> prepare( 'SELECT id FROM pp_pages_langs WHERE page_id=:page_id AND lang_id = :lang_id' );
|
||||
$query2 -> bindValue( ':page_id', $page_id, \PDO::PARAM_INT );
|
||||
$query2 -> bindValue( ':lang_id', $row['id'], \PDO::PARAM_INT );
|
||||
$query2 -> execute();
|
||||
if ( $query2 -> rowCount() )
|
||||
{
|
||||
$query3 = $db -> prepare( 'UPDATE
|
||||
pp_pages_langs
|
||||
SET
|
||||
seo_link = :seo_link, title = :title, meta_description = :meta_description, meta_keywords = :meta_keywords, meta_title = :meta_title
|
||||
WHERE
|
||||
page_id = :page_id AND lang_id = :lang_id' );
|
||||
$query3 -> bindValue( ':page_id', $page_id, \PDO::PARAM_INT );
|
||||
$query3 -> bindValue( ':lang_id', $row['id'], \PDO::PARAM_INT );
|
||||
$query3 -> bindValue( ':title', $title, \PDO::PARAM_STR );
|
||||
$query3 -> bindValue( ':meta_description', $meta_description, \PDO::PARAM_STR );
|
||||
$query3 -> bindValue( ':meta_keywords', $meta_keywords, \PDO::PARAM_STR );
|
||||
$query3 -> bindValue( ':seo_link', $seo_link, \PDO::PARAM_STR );
|
||||
$query3 -> bindValue( ':meta_title', $meta_title, \PDO::PARAM_STR );
|
||||
$query3 -> execute();
|
||||
$query3 -> closeCursor();
|
||||
}
|
||||
else
|
||||
{
|
||||
$query3 = $db -> prepare( 'INSERT INTO
|
||||
pp_pages_langs
|
||||
( page_id, lang_id, title, meta_description, meta_keywords, seo_link, meta_title )
|
||||
VALUES
|
||||
( :page_id, :lang_id, :title, :meta_description, :meta_keywords, :seo_link, :meta_title )' );
|
||||
$query3 -> bindValue( ':page_id', $page_id, \PDO::PARAM_INT );
|
||||
$query3 -> bindValue( ':lang_id', $row['id'], \PDO::PARAM_INT );
|
||||
$query3 -> bindValue( ':title', $title, \PDO::PARAM_STR );
|
||||
$query3 -> bindValue( ':meta_description', $meta_description, \PDO::PARAM_STR );
|
||||
$query3 -> bindValue( ':meta_keywords', $meta_keywords, \PDO::PARAM_STR );
|
||||
$query3 -> bindValue( ':seo_link', $seo_link, \PDO::PARAM_STR );
|
||||
$query3 -> bindValue( ':meta_title', $meta_title, \PDO::PARAM_STR );
|
||||
$query3 -> execute();
|
||||
$query3 -> closeCursor();
|
||||
}
|
||||
$query2 -> closeCursor();
|
||||
}
|
||||
}
|
||||
$query -> closeCursor();
|
||||
\System::rewriteHtacces();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function addPage()
|
||||
{
|
||||
global $db;
|
||||
|
||||
\System::deleteCacheAdmin();
|
||||
\System::deleteCache();
|
||||
|
||||
$enabled = \System::formGet( 'enabled' );
|
||||
$show_title = \System::formGet( 'show_title' );
|
||||
$sort_type = \System::formGet( 'sort_type' );
|
||||
$page_type_id = \System::formGet( 'page_type_id' );
|
||||
$link = \System::formGet( 'link' );
|
||||
$check = \System::formGet( 'check' );
|
||||
$o = \System::formGetInt( 'o' );
|
||||
$article_number = \System::formGetInt( 'article_number' );
|
||||
$parent_id = \System::formGetInt( 'parent_id' );
|
||||
$only_for_logged = \System::formGetInt( 'only_for_logged' );
|
||||
$menu = \System::formGetInt( 'menu_id' );
|
||||
$contact_form = \System::formGetInt( 'contact_form' );
|
||||
$layout_id = \System::formGetInt( 'layout_id' );
|
||||
|
||||
if ( $check != \System::getSessionVar( 'check' ) )
|
||||
{
|
||||
$query = $db -> prepare( 'INSERT INTO pp_pages
|
||||
( only_for_logged, id_menu, id_page_type, id_sort_type, article_number, show_title, enabled, o, parent_id, link, contact_form )
|
||||
VALUES
|
||||
( :only_for_logged, :id_menu, :id_page_type, :id_sort_type, :article_number, :show_title, :enabled, :o, :parent_id, :link, :contact_form )' );
|
||||
$query -> bindValue( ':only_for_logged', $only_for_logged, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':id_menu', $menu, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':id_page_type', $page_type_id, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':id_sort_type', $sort_type, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':article_number', $article_number, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':show_title', $show_title, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':enabled', $enabled, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':o', $o, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':parent_id', $parent_id, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':link', $link, \PDO::PARAM_STR );
|
||||
$query -> bindValue( ':contact_form', $contact_form, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
$query -> closeCursor();
|
||||
|
||||
$page_id = $db -> lastInsertId();
|
||||
|
||||
if ( $page_id )
|
||||
{
|
||||
$query = $db -> prepare( 'INSERT INTO pp_layouts_pages ( layout_id, page_id ) VALUES ( :layout_id, :page_id )' );
|
||||
$query -> bindValue( ':layout_id', $layout_id, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':page_id', $page_id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
$query -> closeCursor();
|
||||
|
||||
$query = $db -> prepare( 'SELECT id FROM pp_langs WHERE enabled = :enabled' );
|
||||
$query -> bindValue( ':enabled', 1, \PDO::PARAM_STR );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
$title = \System::formGet( 'title_' . $row['id'] );
|
||||
$meta_description = \System::formGet( 'meta_description_' . $row['id'] );
|
||||
$meta_keywords = \System::formGet( 'meta_keywords_' . $row['id'] );
|
||||
$meta_title = \System::formGet( 'meta_title_' . $row['id'] );
|
||||
$seo_link = \System::seo( \System::formGet( 'seo_link_' . $row['id'] ) );
|
||||
|
||||
if ( $title )
|
||||
{
|
||||
$query2 = $db -> prepare( 'INSERT INTO
|
||||
pp_pages_langs
|
||||
( page_id, lang_id, title, meta_description, meta_keywords, meta_title, seo_link )
|
||||
VALUES
|
||||
( :page_id, :lang_id, :title, :meta_description, :meta_keywords, :meta_title, :seo_link )' );
|
||||
$query2 -> bindValue( ':page_id', $page_id, \PDO::PARAM_INT );
|
||||
$query2 -> bindValue( ':lang_id', $row['id'], \PDO::PARAM_INT );
|
||||
$query2 -> bindValue( ':title', $title, \PDO::PARAM_STR );
|
||||
$query2 -> bindValue( ':meta_description', $meta_description, \PDO::PARAM_STR );
|
||||
$query2 -> bindValue( ':meta_keywords', $meta_keywords, \PDO::PARAM_STR );
|
||||
$query2 -> bindValue( ':seo_link', $seo_link, \PDO::PARAM_STR );
|
||||
$query2 -> bindValue( ':meta_title', $meta_title, \PDO::PARAM_STR );
|
||||
$query2 -> execute();
|
||||
$query2 -> closeCursor();
|
||||
}
|
||||
}
|
||||
$query -> closeCursor();
|
||||
|
||||
\System::setSessionVar( 'check', $check );
|
||||
\System::rewriteHtacces();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function deletePage( $id )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'SELECT COUNT( 0 ) FROM pp_pages WHERE parent_id = :parent_id' );
|
||||
$query -> bindValue( ':parent_id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
$count = $row[0];
|
||||
$query -> closeCursor();
|
||||
|
||||
if ( $count )
|
||||
{
|
||||
\System::setAlert( 'Strona nie może być usunięta z powodu przypisanych podstron.' );
|
||||
return false;
|
||||
}
|
||||
|
||||
$query = $db -> prepare( 'DELETE FROM pp_layouts_pages WHERE page_id = :page_id' );
|
||||
$query -> bindValue( ':page_id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
$query -> closeCursor();
|
||||
|
||||
$query = $db -> prepare( 'DELETE FROM pp_pages WHERE id = :id' );
|
||||
$query -> bindValue( ':id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
$query -> closeCursor();
|
||||
|
||||
$query = $db -> prepare( 'DELETE FROM pp_pages_langs WHERE page_id = :page_id' );
|
||||
$query -> bindValue( ':page_id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() )
|
||||
{
|
||||
\System::setAlert( 'Strona została usunięta.' );
|
||||
\System::rewriteHtacces();
|
||||
|
||||
\System::deleteCacheAdmin();
|
||||
\System::deleteCache();
|
||||
}
|
||||
$query -> closeCursor();
|
||||
}
|
||||
}
|
||||
?>
|
||||
57
autoload/admin/factory/class.Restriction.php
Normal file
57
autoload/admin/factory/class.Restriction.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?
|
||||
// po poprawkach
|
||||
namespace admin\factory;
|
||||
|
||||
class Restriction
|
||||
{
|
||||
public function isBannedEmail( $email )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare('SELECT id FROM pp_banned_email WHERE email = :email');
|
||||
$query -> bindValue(':email' , $email , \PDO::PARAM_STR);
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
public function isBannedLogin( $login )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare('SELECT id FROM pp_banned_email WHERE login = :login');
|
||||
$query -> bindValue(':login' , $login , \PDO::PARAM_STR);
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
public function deleteBannedEmail( $id )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'DELETE FROM pp_banned_email WHERE id = :id' );
|
||||
$query -> bindValue( ':id' , $id , \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() )
|
||||
\System::setAlert( 'Zbanowany adres email został usunięty.' );
|
||||
$query -> closeCursor();
|
||||
}
|
||||
|
||||
public function deleteBannedLogin( $id )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'DELETE FROM pp_banned_login WHERE id = :id' );
|
||||
$query -> bindValue( ':id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() )
|
||||
\System::setAlert( 'Zbanowany login został usunięty.' );
|
||||
$query -> closeCursor();
|
||||
}
|
||||
}
|
||||
?>
|
||||
174
autoload/admin/factory/class.SContainers.php
Normal file
174
autoload/admin/factory/class.SContainers.php
Normal file
@@ -0,0 +1,174 @@
|
||||
<?php
|
||||
namespace admin\factory;
|
||||
|
||||
class SContainers {
|
||||
|
||||
public function deleteContainer( $id )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'DELETE FROM pp_static_container_langs WHERE static_container_id = :static_container_id' );
|
||||
$query -> bindValue( ':static_container_id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
$query -> closeCursor();
|
||||
|
||||
$query = $db -> prepare( 'DELETE FROM pp_static_container WHERE id = :id' );
|
||||
$query -> bindValue( ':id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() )
|
||||
return true;
|
||||
$query -> closeCursor();
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getContainer( $id )
|
||||
{
|
||||
global $db, $lang;
|
||||
|
||||
$query = $db -> prepare( 'SELECT * FROM pp_static_container WHERE id = :id' );
|
||||
$query -> bindValue( ':id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
$query2 = $db -> prepare( 'SELECT * FROM pp_static_container_langs WHERE static_container_id = :static_container_id AND lang_id = :lang_id' );
|
||||
$query2 -> bindValue( ':static_container_id', $id, \PDO::PARAM_INT );
|
||||
$query2 -> bindValue( ':lang_id', $lang -> get_language(), \PDO::PARAM_INT );
|
||||
$query2 -> execute();
|
||||
if ( $query2 -> rowCount() ) while ( $row2 = $query2 -> fetch() )
|
||||
$row['content'] = $row2['content'];
|
||||
return $row;
|
||||
}
|
||||
$query -> closeCursor();
|
||||
return false;
|
||||
}
|
||||
|
||||
public function saveContainer()
|
||||
{
|
||||
global $db;
|
||||
|
||||
$id = \System::formGetInt( 'id' );
|
||||
$name = \System::formGet( 'name' );
|
||||
$enabled = \System::formGet( 'enabled' );
|
||||
|
||||
$query = $db -> prepare( 'UPDATE pp_static_container SET name = :name, enabled = :enabled WHERE id = :id' );
|
||||
$query -> bindValue( ':enabled', $enabled, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':name', $name, \PDO::PARAM_STR );
|
||||
$query -> bindValue( ':id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
$query -> closeCursor();
|
||||
|
||||
if ( $id )
|
||||
{
|
||||
$query = $db -> prepare( 'SELECT id FROM pp_langs WHERE enabled = :enabled' );
|
||||
$query -> bindValue( ':enabled', 1, \PDO::PARAM_STR );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
$text = \System::formGet( 'text_' . $row['id'] );
|
||||
|
||||
if ( $text )
|
||||
{
|
||||
$query2 = $db -> prepare( 'SELECT id FROM pp_static_container_langs WHERE static_container_id = :static_container_id AND lang_id = :lang_id' );
|
||||
$query2 -> bindValue( ':static_container_id', $id, \PDO::PARAM_INT );
|
||||
$query2 -> bindValue( ':lang_id', $row['id'], \PDO::PARAM_INT );
|
||||
$query2 -> execute();
|
||||
if ( $query2 -> rowCount() )
|
||||
{
|
||||
$query3 = $db -> prepare( 'UPDATE pp_static_container_langs SET content = :content WHERE static_container_id = :static_container_id AND lang_id = :lang_id' );
|
||||
$query3 -> bindValue( ':static_container_id', $id, \PDO::PARAM_INT );
|
||||
$query3 -> bindValue( ':lang_id', $row['id'], \PDO::PARAM_INT );
|
||||
$query3 -> bindValue( ':content', $text, \PDO::PARAM_STR );
|
||||
$query3 -> execute();
|
||||
$query3 -> closeCursor();
|
||||
}
|
||||
else
|
||||
{
|
||||
$query3 = $db -> prepare( 'INSERT INTO pp_static_container_langs ( static_container_id, lang_id, content ) VALUES ( :static_container_id, :lang_id, :content )' );
|
||||
$query3 -> bindValue( ':static_container_id', $id, \PDO::PARAM_INT );
|
||||
$query3 -> bindValue( ':lang_id', $row['id'], \PDO::PARAM_INT );
|
||||
$query3 -> bindValue( ':content', $text, \PDO::PARAM_STR );
|
||||
$query3 -> execute();
|
||||
$query3 -> closeCursor();
|
||||
}
|
||||
$query2 -> closeCursor();
|
||||
}
|
||||
}
|
||||
$query -> closeCursor();
|
||||
\System::rewriteHtacces();
|
||||
\System::setAlert( 'Strona została zapisana.' );
|
||||
}
|
||||
}
|
||||
|
||||
public function addContainer()
|
||||
{
|
||||
global $db;
|
||||
|
||||
$name = \System::formGet( 'name' );
|
||||
$enabled = \System::formGet( 'enabled' );
|
||||
$check = \System::formGet( 'check' );
|
||||
|
||||
if ( \System::getSessionVar( 'check' ) != $check )
|
||||
{
|
||||
$query = $db -> prepare( 'INSERT INTO pp_static_container ( name, enabled ) VALUES ( :name, :enabled )' );
|
||||
$query -> bindValue( ':name', $name, \PDO::PARAM_STR );
|
||||
$query -> bindValue( ':enabled', $enabled, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
$query -> closeCursor();
|
||||
|
||||
$container_id = $db -> lastInsertId();
|
||||
|
||||
if ( $container_id )
|
||||
{
|
||||
$query = $db -> prepare( 'SELECT id FROM pp_langs WHERE enabled = :enabled' );
|
||||
$query -> bindValue( ':enabled', 1, \PDO::PARAM_STR );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
$text = \System::formGet( 'text_' . $row['id'] );
|
||||
|
||||
if ( $text )
|
||||
{
|
||||
$query2 = $db -> prepare( 'INSERT INTO pp_static_container_langs ( static_container_id, lang_id, content ) VALUES ( :static_container_id, :lang_id, :content )' );
|
||||
$query2 -> bindValue( ':static_container_id', $container_id, \PDO::PARAM_INT );
|
||||
$query2 -> bindValue( ':lang_id', $row['id'], \PDO::PARAM_INT );
|
||||
$query2 -> bindValue( ':content', $text, \PDO::PARAM_STR );
|
||||
$query2 -> execute();
|
||||
$query2 -> closeCursor();
|
||||
}
|
||||
}
|
||||
$query -> closeCursor();
|
||||
|
||||
\System::setSessionVar( 'check', $check );
|
||||
\System::setAlert( 'Kontener został dodany.' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getContainerParamLanguage( $id = '' )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'SELECT id, name FROM pp_langs WHERE enabled = :enabled' );
|
||||
$query -> bindValue( ':enabled', 1, \PDO::PARAM_STR );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
unset( $lg );
|
||||
|
||||
$query2 = $db -> prepare( 'SELECT * FROM pp_static_container_langs WHERE static_container_id = :static_container_id AND lang_id = :lang_id' );
|
||||
$query2 -> bindValue( ':static_container_id', $id, \PDO::PARAM_INT );
|
||||
$query2 -> bindValue( ':lang_id', $row['id'], \PDO::PARAM_STR );
|
||||
$query2 -> execute();
|
||||
if ( $query2 -> rowCount() ) while ( $row2 = $query2 -> fetch() )
|
||||
$lg = $row2;
|
||||
$query2 -> closeCursor();
|
||||
|
||||
$lg['id'] = $row['id'];
|
||||
$lg['name'] = $row['name'];
|
||||
$language[] = $lg;
|
||||
}
|
||||
$query -> closeCursor();
|
||||
|
||||
return $language;
|
||||
}
|
||||
}
|
||||
117
autoload/admin/factory/class.Settings.php
Normal file
117
autoload/admin/factory/class.Settings.php
Normal file
@@ -0,0 +1,117 @@
|
||||
<?
|
||||
namespace admin\factory;
|
||||
|
||||
class Settings
|
||||
{
|
||||
public static function getSystemSettings( $param )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'SELECT value FROM pp_settings WHERE param = :param' );
|
||||
$query -> bindValue( ':param' , $param , \PDO::PARAM_STR );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
$out = $row['value'];
|
||||
$query -> closeCursor();
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
public static function saveSettings()
|
||||
{
|
||||
$firm_name = \System::saveString( \System::formGet( 'firm_name' ) );
|
||||
\admin\factory\Settings::saveParam( 'firm_name' , $firm_name );
|
||||
|
||||
$street = \System::saveString( \System::formGet( 'street' ) );
|
||||
\admin\factory\Settings::saveParam( 'street' , $street );
|
||||
|
||||
$postal_code = \System::saveString( \System::formGet( 'postal_code' ) );
|
||||
\admin\factory\Settings::saveParam( 'postal_code' , $postal_code );
|
||||
|
||||
$city = \System::saveString( \System::formGet( 'city' ) );
|
||||
\admin\factory\Settings::saveParam( 'city' , $city );
|
||||
|
||||
$nip = \System::saveString( \System::formGet( 'nip' ) );
|
||||
\admin\factory\Settings::saveParam( 'nip' , $nip );
|
||||
|
||||
$email = \System::saveString( \System::formGet( 'email' ) );
|
||||
\admin\factory\Settings::saveParam( 'email' , $email );
|
||||
|
||||
$phone = \System::saveString( \System::formGet( 'phone' ) );
|
||||
\admin\factory\Settings::saveParam( 'phone' , $phone );
|
||||
|
||||
$fax = \System::saveString( \System::formGet( 'fax' ) );
|
||||
\admin\factory\Settings::saveParam( 'fax' , $fax );
|
||||
|
||||
$account = \System::saveString( \System::formGet( 'account' ) );
|
||||
\admin\factory\Settings::saveParam( 'account' , $account );
|
||||
|
||||
$person = \System::saveString( \System::formGet( 'person' ) );
|
||||
\admin\factory\Settings::saveParam( 'person' , $person );
|
||||
|
||||
$admin_email = \System::saveString( \System::formGet( 'admin_email' ) );
|
||||
\admin\factory\Settings::saveParam( 'admin_email' , $admin_email );
|
||||
|
||||
$email_host = \System::saveString( \System::formGet( 'email_host' ) );
|
||||
\admin\factory\Settings::saveParam( 'email_host' , $email_host );
|
||||
|
||||
$email_port = \System::saveString( \System::formGet( 'email_port' ) );
|
||||
\admin\factory\Settings::saveParam( 'email_port' , $email_port );
|
||||
|
||||
$email_login = \System::saveString( \System::formGet( 'email_login' ) );
|
||||
\admin\factory\Settings::saveParam( 'email_login' , $email_login );
|
||||
|
||||
$email_password = \System::saveString( \System::formGet( 'email_password' ) );
|
||||
\admin\factory\Settings::saveParam( 'email_password' , $email_password );
|
||||
|
||||
$google_map_key = \System::saveString( \System::formGet( 'google_map_key' ) );
|
||||
\admin\factory\Settings::saveParam( 'google_map_key' , $google_map_key );
|
||||
|
||||
$facebook_url = \System::saveString( \System::formGet( 'facebook_url' ) );
|
||||
\admin\factory\Settings::saveParam( 'facebook_url' , $facebook_url );
|
||||
|
||||
|
||||
$user_register = \System::saveString( \System::formGet( 'user_register' ) );
|
||||
\admin\factory\Settings::saveParam( 'user_register' , $user_register );
|
||||
|
||||
$contact_form = \System::saveString( \System::formGet( 'contact_form' ) );
|
||||
\admin\factory\Settings::saveParam( 'contact_form' , $contact_form );
|
||||
|
||||
$register = \System::formGetInt( 'register' );
|
||||
\admin\factory\Settings::saveParam( 'register' , $register );
|
||||
|
||||
$info = \System::formGet( 'info' );
|
||||
\admin\factory\Settings::saveParam( 'info' , $info );
|
||||
|
||||
\System::deleteCacheAdmin();
|
||||
\System::deleteCache();
|
||||
\System::setAlert( 'Ustawienia zostały zapisane.' );
|
||||
}
|
||||
|
||||
public static function saveParam( $param, $value )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'SELECT id FROM pp_settings WHERE param = :param' );
|
||||
$query -> bindValue( ':param', $param, \PDO::PARAM_STR );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() )
|
||||
{
|
||||
$query2 = $db -> prepare( 'UPDATE pp_settings SET value = :value WHERE param = :param' );
|
||||
$query2 -> bindValue( ':value' , $value , \PDO::PARAM_STR );
|
||||
$query2 -> bindValue( ':param' , $param , \PDO::PARAM_STR );
|
||||
$query2 -> execute();
|
||||
$query2 -> closeCursor();
|
||||
}
|
||||
else
|
||||
{
|
||||
$query2 = $db -> prepare( 'INSERT INTO pp_settings ( value, param ) VALUES ( :value, :param )' );
|
||||
$query2 -> bindValue( ':value' , $value , \PDO::PARAM_STR );
|
||||
$query2 -> bindValue( ':param' , $param , \PDO::PARAM_STR );
|
||||
$query2 -> execute();
|
||||
$query2 -> closeCursor();
|
||||
}
|
||||
$query -> closeCursor();
|
||||
}
|
||||
}
|
||||
?>
|
||||
31
autoload/admin/factory/class.Users.php
Normal file
31
autoload/admin/factory/class.Users.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
// po poprawkach
|
||||
namespace admin\factory;
|
||||
|
||||
class Users {
|
||||
|
||||
public function deleteAdmin( $id )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'DELETE FROM pp_users WHERE id = :id' );
|
||||
$query -> bindValue( ':id' , $id , \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() )
|
||||
\System::setAlert( 'Administrator został usunięty.' );
|
||||
$query -> closeCursor();
|
||||
}
|
||||
|
||||
public function deleteUser( $id )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'DELETE FROM pp_users WHERE id = :id' );
|
||||
$query -> bindValue( ':id' , $id , \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() )
|
||||
\System::setAlert( 'Użytkownik został usunięty.' );
|
||||
$query -> closeCursor();
|
||||
}
|
||||
}
|
||||
?>
|
||||
49
autoload/admin/view/class.Adverts.php
Normal file
49
autoload/admin/view/class.Adverts.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
// po poprawkach
|
||||
namespace admin\view;
|
||||
|
||||
class Adverts {
|
||||
|
||||
public function editAdvert( $id = '' )
|
||||
{
|
||||
$id ? $value = 'Zapisz' : $value = 'Dodaj';
|
||||
|
||||
$out = \admin\view\PagePanel::show( false, $value, true, 'Reklama' );
|
||||
|
||||
$dbedit = new \DataEdit( 'pp_adverts', 'id', $id );
|
||||
$dbedit -> addPosition( 'name', 'Nazwa', 'text' );
|
||||
$dbedit -> addPosition( 'date_start', 'Początek', 'text', 'onFocus="if ( $( this ).val() == \'\' ) $(this).val( \'' . date( 'Y-m-d' ) . '\');"' );
|
||||
$dbedit -> addPosition( 'date_end', 'Koniec', 'text', 'onFocus="if ( $( this ).val() == \'\' ) $(this).val( \'' . date( 'Y-m-d' ) . '\');"' );
|
||||
$dbedit -> addPosition( 'enabled', 'Aktywna', 'radio' , '' , \System::getComboYesNo() );
|
||||
$dbedit -> addPosition( 'img', 'Obraz', 'file' );
|
||||
$dbedit -> setUploadFolder( 'image' , 'upload/adverts/' );
|
||||
$out .= $dbedit -> draw();
|
||||
|
||||
$tpl = new \Savant3;
|
||||
$out .= $tpl -> fetch( 'adverts/adverts-edit' );
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
public function showAdverts()
|
||||
{
|
||||
$out = \admin\view\PagePanel::show( 'Dodaj nową', false, false, 'Reklama' );
|
||||
|
||||
$dbrowse = new \DataBrowse( 'pp_adverts' );
|
||||
$dbrowse -> addPosition( 'name', 'Nazwa', '', '', '', 'name' );
|
||||
$dbrowse -> addPosition( 'date_start', 'Początek', '', '', '', 'date_start' );
|
||||
$dbrowse -> addPosition( 'date_end', 'Koniec', '', '', '', 'date_end' );
|
||||
$dbrowse -> addPosition( 'enabled', 'Aktywna', '' , \System::getComboYesNo() );
|
||||
$dbrowse -> addPositionSimple( 'edytuj', '', './?rw=edit' );
|
||||
$dbrowse -> addPositionSimple( 'usuń', '', '', \System::deleteAction() );
|
||||
$dbrowse -> setParam( 'id' );
|
||||
$dbrowse -> addSort( 'name ASC' );
|
||||
$dbrowse -> addLp();
|
||||
$dbrowse -> addFiltr( 'name', 'Nazwa' );
|
||||
$dbrowse -> addFiltr( 'enabled', 'Aktywna', \System::getComboYesNo() );
|
||||
$out .= $dbrowse -> draw();
|
||||
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
?>
|
||||
202
autoload/admin/view/class.Articles.php
Normal file
202
autoload/admin/view/class.Articles.php
Normal file
@@ -0,0 +1,202 @@
|
||||
<?php
|
||||
// po poprawkach
|
||||
namespace admin\view;
|
||||
|
||||
class Articles
|
||||
{
|
||||
public static function drawPagesArticles()
|
||||
{
|
||||
$tpl = new \Savant3();
|
||||
$tpl -> _pages = \admin\factory\Articles::getPagesWithArticles();
|
||||
return $tpl -> fetch( 'articles/article-sort' );
|
||||
}
|
||||
|
||||
public static function showArticlesArchive()
|
||||
{
|
||||
$delete_articles = "var articles = ''; $('input:checkbox:checked').each( function() { if ( articles != '' ) articles = articles + ':'; articles = articles + $(this).val(); } ); $.prompt( 'Trwa usuwanie...' ); xajax_deleteArticles( articles );";
|
||||
|
||||
$tab_comment[0] = 'nie';
|
||||
$tab_comment[1] = 'tak';
|
||||
$tab_comment[2] = 'tylko dla zarejestrowanych';
|
||||
|
||||
$tab = \System::getArticlesTitle();
|
||||
|
||||
$dbrowse = new \DataBrowse( 'pp_articles', 'archive = 1' );
|
||||
$dbrowse -> addPosition( 'id', 'Tytuł', '', $tab, '' );
|
||||
$dbrowse -> addPosition( 'enabled', 'Opublikowany', '', \System::getComboYesNo(), 'text-align: center; width: 100px;' );
|
||||
$dbrowse -> addPosition( 'date_modify', 'Data modyfikacji', '', '', 'width: 150px; text-align: center;', true );
|
||||
$dbrowse -> addPositionSimple( 'przywróc', '', './?rw=restore' );
|
||||
$dbrowse -> addPositionSimple( 'usuń', '', '', \System::deleteAction() );
|
||||
$dbrowse -> setParam( 'id' );
|
||||
$dbrowse -> addSort( 'date_add DESC' );
|
||||
$dbrowse -> addLp();
|
||||
$dbrowse -> addCheckbox();
|
||||
$dbrowse -> addFiltr( 'id{trans}', 'Tytuł', $tab );
|
||||
$dbrowse -> addFiltr( 'print', 'Drukuj', \System::getComboYesNo() );
|
||||
$dbrowse -> addFiltr( 'enabled', 'Opublikowany', \System::getComboYesNo() );
|
||||
$dbrowse -> addFiltr( 'show_title', 'Pokaż tytuł', \System::getComboYesNo() );
|
||||
$dbrowse -> addMenu( \admin\view\PagePanel::show( false, false, false, 'Archiwum', 'formularz', false, false, false, $delete_articles ) );
|
||||
$out .= $dbrowse -> draw();
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
public static function drawArticle( $version_id )
|
||||
{
|
||||
$article_id = \admin\factory\Articles::getArticleIdByVersionId( $version_id );
|
||||
$version = \admin\factory\Articles::getArticleVersionByVersionId( $version_id );
|
||||
$language = \admin\factory\Articles::getArticleParamLanguage( $article_id , $version );
|
||||
|
||||
$out = \admin\view\PagePanel::show( false , false , true );
|
||||
|
||||
$tpl = new \Savant3();
|
||||
$tpl -> _language = $language;
|
||||
$out .= $tpl -> fetch( 'articles/article-draw' );
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
public static function addArticle()
|
||||
{
|
||||
\System::deleteSessionVar( 'id_menu' );
|
||||
|
||||
$out = \admin\view\PagePanel::show( false, 'Dodaj', true, 'Artykuły', 'formularz', false, false, 'saveArticle()' );
|
||||
|
||||
$pages = \admin\factory\Articles::getPagesAssign();
|
||||
$language = \admin\factory\Articles::getArticleParamLanguage();
|
||||
|
||||
$tpl = new \Savant3();
|
||||
$tpl -> _language = $language;
|
||||
$tpl -> _rw = 'add';
|
||||
$tpl -> _pages = $pages;
|
||||
$tpl -> _id_form = 'formularz';
|
||||
$tpl -> _layouts = \admin\factory\Layouts::getLayouts();
|
||||
$out .= $tpl -> fetch( 'articles/article-edit' );
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
public static function drawArticleEditPages( $pages, $step = 0 )
|
||||
{
|
||||
$tpl = new \Savant3;
|
||||
$tpl -> _pages = $pages;
|
||||
$tpl -> _step = $step;
|
||||
return $tpl -> fetch( 'articles/article-edit-pages' );
|
||||
}
|
||||
|
||||
public static function editArticle( $id )
|
||||
{
|
||||
\System::deleteSessionVar( 'id_menu' );
|
||||
|
||||
$out = \admin\view\PagePanel::show( false, 'Zapisz', true, 'Artykuły', 'formularz', false, false, 'saveArticle()' );
|
||||
|
||||
$article = \admin\factory\Articles::getArticleParam( $id );
|
||||
$pages = \admin\factory\Articles::getPagesAssign( $id );
|
||||
$language = \admin\factory\Articles::getArticleParamLanguage( $id );
|
||||
|
||||
$tpl = new \Savant3();
|
||||
$tpl -> _article = $article;
|
||||
$tpl -> _language = $language;
|
||||
$tpl -> _pages = $pages;
|
||||
$tpl -> _layouts = \admin\factory\Layouts::getLayouts();
|
||||
$tpl -> _version = \admin\factory\Articles::getMaxArticleVersion( $id ) + 1;
|
||||
$tpl -> _images = \admin\factory\Articles::getArticleImages( $id );
|
||||
$tpl -> _files = \admin\factory\Articles::getArticleFiles( $id );
|
||||
$out .= $tpl -> fetch( 'articles/article-edit' );
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
public static function showVersions( $id )
|
||||
{
|
||||
global $bs;
|
||||
|
||||
$out = \admin\view\PagePanel::show( false, false, false, 'Artykuł: ' . \article\FArticle::getArticleTitle( $id ), '', true );
|
||||
|
||||
$lpk = 25;
|
||||
|
||||
if ( \System::formGetInt( 'r' ) )
|
||||
\System::setSessionVar( 'pcms_page_limit' , \System::formGetInt( 'r' ) );
|
||||
|
||||
$limit = \System::getSessionVar( 'pcms_page_limit' );
|
||||
$limit = \System::checkBrowseLimit( $limit );
|
||||
$link = './';
|
||||
|
||||
$count_page = \admin\factory\Articles::getCountVersions( $id );
|
||||
|
||||
$tpl = new \Savant3;
|
||||
|
||||
$ls = ceil( $count_page / $lpk );
|
||||
if ( $bs < 1 )
|
||||
$bs = 1;
|
||||
else if ( $bs > $ls )
|
||||
$bs = $ls;
|
||||
|
||||
$a = \System::getPagingVar( "a" , $bs , $ls );
|
||||
$b = \System::getPagingVar( "b" , $bs , $ls );
|
||||
|
||||
$tpl -> _a = $bs - $b;
|
||||
$tpl -> _b = $bs + $a;
|
||||
$tpl -> _ls = $ls;
|
||||
$tpl -> _link = $link;
|
||||
$tpl -> _bs = $bs;
|
||||
|
||||
$from = $lpk * ( $bs - 1 );
|
||||
if ( $from < 0 )
|
||||
$from = 0;
|
||||
$lp = $from + 1;
|
||||
|
||||
$articles = \admin\factory\Articles::getVersions( $id , $from , $lpk );
|
||||
|
||||
$tpl -> _articles = $articles;
|
||||
$tpl -> _bs = $bs;
|
||||
$tpl -> _limit = $lpk;
|
||||
$tpl -> _total = $count_page;
|
||||
$tpl -> _start = $lpk * ( $bs - 1 ) + 1 < 0 ? 0 : $lpk * ( $bs - 1 ) + 1;
|
||||
if ( $count_page == 0 )
|
||||
$tpl -> _start = 0;
|
||||
$tpl -> _end = $lpk * $bs > $count_page ? $count_page : $lpk * $bs;
|
||||
$out .= $tpl -> fetch( 'articles/article-versions' );
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
public static function showArticles()
|
||||
{
|
||||
$delete = "var articles = ''; $('input:checkbox:checked').each( function() { if ( articles != '' ) articles = articles + ':'; articles = articles + $(this).val(); } ); $.prompt( 'Trwa przenoszenie do archiwum...' ); xajax_moveArticlesToArchive( articles );";
|
||||
|
||||
$change = "$.prompt( 'Na pewno chcesz wykonać wybraną czynność?',{ submit: function(e,v,m,f) { if ( v == true ) document.location.href='./?rw=change-enabled&id=[param]'; }, buttons: { tak: true, nie: false }, focus: 1 })";
|
||||
$change = 'onClick="' . $change . '"';
|
||||
|
||||
|
||||
$clone = "$.prompt( 'Na pewno chcesz wykonać wybraną czynność?',{ submit: function(e,v,m,f) { if ( v == true ) xajax_cloneArticle( [param] ); }, buttons: { 'tak': true, 'nie': false }, focus: 1 })";
|
||||
$clone = 'onClick="' . $clone . '"';
|
||||
|
||||
$tab_comment[0] = 'nie';
|
||||
$tab_comment[1] = 'tak';
|
||||
$tab_comment[2] = 'tylko dla zarejestrowanych';
|
||||
|
||||
$tab = \System::getArticlesTitle();
|
||||
|
||||
$dbrowse = new \DataBrowse( 'pp_articles', 'archive = 0' );
|
||||
$dbrowse -> addPosition( 'id', 'Tytuł', '', $tab );
|
||||
$dbrowse -> addPosition( 'enabled', 'Opublikowany', '', \System::getComboYesNo(), 'cursor: pointer; width: 100px; text-align: center;', false, false, $change );
|
||||
$dbrowse -> addPosition( 'date_modify', 'Data modyfikacji', '', '', 'width: 150px; text-align: center;', 'date_modify' );
|
||||
$dbrowse -> addPositionSimple( 'duplikuj', '', '', $clone );
|
||||
$dbrowse -> addPositionSimple( 'pokaż', '', './?act=show_versions' );
|
||||
$dbrowse -> addPositionSimple( 'edytuj', '', './?rw=edit' );
|
||||
$dbrowse -> addPositionSimple( 'usuń', '', '', \System::deleteAction() );
|
||||
$dbrowse -> setParam( 'id' );
|
||||
$dbrowse -> addSort( 'date_add DESC' );
|
||||
$dbrowse -> addLp();
|
||||
$dbrowse -> addCheckbox();
|
||||
$dbrowse -> addFiltr( 'id{trans}', 'Tytuł', $tab );
|
||||
$dbrowse -> addFiltr( 'enabled', 'Opublikowany', \System::getComboYesNo() );
|
||||
$dbrowse -> addFiltr( 'show_title', 'Pokaż tytuł', \System::getComboYesNo() );
|
||||
$dbrowse -> addMenu( \admin\view\PagePanel::show( true, false, false, 'Artykuły', 'formularz', false, false, false, $delete ) );
|
||||
$out .= $dbrowse -> draw();
|
||||
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
?>
|
||||
78
autoload/admin/view/class.Banners.php
Normal file
78
autoload/admin/view/class.Banners.php
Normal file
@@ -0,0 +1,78 @@
|
||||
<?
|
||||
namespace admin\view;
|
||||
|
||||
class Banners
|
||||
{
|
||||
public static function showBanners()
|
||||
{
|
||||
global $bs;
|
||||
|
||||
$out = \admin\view\PagePanel::show( 'Dodaj nowy', false, false, 'Banery' );
|
||||
|
||||
$lpk = 25;
|
||||
|
||||
if ( \System::formGetInt('r') )
|
||||
\System::setSessionVar( 'pp_banner_limit' , \System::formGetInt('r') );
|
||||
|
||||
$limit = \System::getSessionVar( 'pp_banner_limit' );
|
||||
$limit = \System::checkBrowseLimit( $limit );
|
||||
$link = './';
|
||||
|
||||
$banners_count = \admin\factory\Banners::getCountBanners();
|
||||
|
||||
$tpl = new \Savant3;
|
||||
|
||||
$ls = ceil( $banners_count / $lpk );
|
||||
if ( $bs < 1 )
|
||||
$bs = 1;
|
||||
else if ( $bs > $ls )
|
||||
$bs = $ls;
|
||||
|
||||
$a = \System::getPagingVar( 'a', $bs, $ls );
|
||||
$b = \System::getPagingVar( 'b', $bs, $ls );
|
||||
$tpl -> _a = $bs - $b;
|
||||
$tpl -> _b = $bs + $a;
|
||||
$tpl -> _ls = $ls;
|
||||
$tpl -> _link = $link;
|
||||
$tpl -> _bs = $bs;
|
||||
|
||||
$from = $lpk * ( $bs - 1 );
|
||||
if ( $from < 0 )
|
||||
$from = 0;
|
||||
$lp = $from+1;
|
||||
|
||||
$banners = \admin\factory\Banners::getBanners( $from, $lpk );
|
||||
|
||||
$tpl -> _banners = $banners;
|
||||
$tpl -> _bs = $bs;
|
||||
$tpl -> _limit = $lpk;
|
||||
$tpl -> _total = $banners_count;
|
||||
$tpl -> _start = $lpk * ( $bs - 1 ) + 1 > 0 ? $lpk * ( $bs - 1 ) + 1 : 0;
|
||||
$tpl -> _end = $lpk * $bs > $banners_count ? $banners_count : $lpk * $bs;
|
||||
|
||||
$out .= $tpl -> fetch( 'other/banner' );
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
public static function editBanner( $id = '' )
|
||||
{
|
||||
$id ? $value = 'Zapisz' : $value = 'Dodaj';
|
||||
$order = \admin\factory\Banners::getMaxOrder();
|
||||
|
||||
$out = \admin\view\PagePanel::show( false, $value, true, 'Banery' );
|
||||
|
||||
$dbedit = new \DataEdit( 'pp_banner' , 'id' , $id );
|
||||
$dbedit -> addPosition( 'title', 'Tytuł', 'text' );
|
||||
$dbedit -> addPosition( 'link', 'Link', 'text' );
|
||||
$dbedit -> addPosition( 'enabled', 'Aktywny', 'radio' , '' , \System::getComboYesNo() );
|
||||
$dbedit -> addPosition( 'image', 'Obraz', 'file' );
|
||||
$dbedit -> setUploadFolder( 'image' , 'upload/banner/' );
|
||||
if ( !$id )
|
||||
$dbedit -> addPositionHidden( 'o' , $order );
|
||||
$out .= $dbedit -> draw();
|
||||
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
?>
|
||||
12
autoload/admin/view/class.FileManager.php
Normal file
12
autoload/admin/view/class.FileManager.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
namespace admin\view;
|
||||
|
||||
class FileManager {
|
||||
|
||||
public function showFileManager()
|
||||
{
|
||||
$tpl = new \Savant3;
|
||||
return $tpl -> fetch( 'other/filemanager' );
|
||||
}
|
||||
}
|
||||
?>
|
||||
42
autoload/admin/view/class.GuestBook.php
Normal file
42
autoload/admin/view/class.GuestBook.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?
|
||||
// po poprwakach
|
||||
namespace admin\view;
|
||||
|
||||
class GuestBook
|
||||
{
|
||||
public function showEntries()
|
||||
{
|
||||
$out = \admin\view\PagePanel::show( 'Dodaj wpis', false, false, 'Księga gości' );
|
||||
|
||||
$dbrowse = new \DataBrowse( 'pp_guest_book' );
|
||||
$dbrowse -> addPosition( 'signature', 'Podpis', '' , '' , '' , 'signature' );
|
||||
$dbrowse -> addPosition( 'text', 'Treść', '' , '' , '' , 'text' );
|
||||
$dbrowse -> addPosition( 'date', 'Data', '' , '' , '' , 'date' );
|
||||
$dbrowse -> addPositionSimple( 'edytuj', '' , './?rw=edit' );
|
||||
$dbrowse -> addPositionSimple( 'usuń', '' , '', \System::deleteAction() );
|
||||
$dbrowse -> setParam( 'id' );
|
||||
$dbrowse -> addSort( 'date DESC' );
|
||||
$dbrowse -> addLp();
|
||||
$dbrowse -> addFiltr( 'signature', 'Podpis', 'text' );
|
||||
$dbrowse -> addFiltr( 'text', 'Treść', 'text' );
|
||||
$out .= $dbrowse -> draw();
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
public function editEntry( $id = '' )
|
||||
{
|
||||
$id ? $value = 'Zapisz' : $value = 'Dodaj';
|
||||
|
||||
$out = \admin\view\PagePanel::show( false, $value, true, 'Księga gości' );
|
||||
|
||||
$dbedit = new \DataEdit( 'pp_guest_book', 'id', $id );
|
||||
$dbedit -> addPosition( 'signature', 'Podpis', 'text' );
|
||||
$dbedit -> addPosition( 'text', 'Treść', 'textarea' );
|
||||
$dbedit -> addPosition( 'date', 'Data', 'text' );
|
||||
$out .= $dbedit -> draw();
|
||||
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
?>
|
||||
86
autoload/admin/view/class.Languages.php
Normal file
86
autoload/admin/view/class.Languages.php
Normal file
@@ -0,0 +1,86 @@
|
||||
<?
|
||||
// po poprawkach
|
||||
namespace admin\view;
|
||||
|
||||
class Languages
|
||||
{
|
||||
public function editTranslation( $id = '' )
|
||||
{
|
||||
$out = \admin\view\PagePanel::show( false, true, true, 'Tłumaczenia' );
|
||||
|
||||
$id ? $type = 'label' : $type = 'text';
|
||||
|
||||
$dbedit = new \DataEdit( 'pp_langs_text' , 'id' , $id );
|
||||
$dbedit -> addPosition( 'text', 'Tekst', $type );
|
||||
$dbedit -> addPosition( 'pl', 'Polski', 'textarea' );
|
||||
$dbedit -> addPosition( 'en', 'Angielski', 'textarea' );
|
||||
$dbedit -> addPosition( 'ru', 'Rosyjski', 'textarea' );
|
||||
$dbedit -> addPosition( 'de', 'Niemiecki', 'textarea' );
|
||||
$dbedit -> addPosition( 'uk', 'Ukraiński', 'textarea' );
|
||||
$out .= $dbedit -> draw();
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
public function showTranslations()
|
||||
{
|
||||
$delete = " var translations = '';
|
||||
$('input:checkbox:checked').each(
|
||||
function() {
|
||||
if ( translations != '' )
|
||||
translations = translations + ':';
|
||||
translations = translations + $(this).val();
|
||||
}
|
||||
);
|
||||
$.prompt( 'Trwa usuwanie tłumaczeń...' );
|
||||
xajax_deleteTranslations( translations );";
|
||||
|
||||
$out = \admin\view\PagePanel::show( true, false, false, 'Tłumaczenia', '', false, false, false, $delete );
|
||||
|
||||
$dbrowse = new \DataBrowse( 'pp_langs_text' );
|
||||
$dbrowse -> addPosition( 'text', 'Tekst', '', '', '', 'text' );
|
||||
$dbrowse -> addPosition( 'pl', 'Polski', '', '', '', 'pl' );
|
||||
$dbrowse -> addPosition( 'en', 'Angielski', '', '', '', 'en' );
|
||||
$dbrowse -> addPositionSimple( 'edytuj', '', './?rw=edit' );
|
||||
$dbrowse -> addPositionSimple( 'usuń', '', '', \System::deleteAction() );
|
||||
$dbrowse -> setParam( 'id' );
|
||||
$dbrowse -> addSort( 'text ASC' );
|
||||
$dbrowse -> addLp();
|
||||
$dbrowse -> addCheckbox();
|
||||
$dbrowse -> addFiltr( 'text', 'Tekst', 'text' );
|
||||
$dbrowse -> addFiltr( 'pl', 'Polski', 'text' );
|
||||
$out .= $dbrowse -> draw();
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
public function showLanguages()
|
||||
{
|
||||
$out = \admin\view\PagePanel::show( false, false, false, 'Języki' );
|
||||
|
||||
$dbrowse = new \DataBrowse( 'pp_langs' );
|
||||
$dbrowse -> addPosition( 'id', 'Id', '', '', '', 'id' );
|
||||
$dbrowse -> addPosition( 'name', 'Nazwa', '', '', '', 'name' );
|
||||
$dbrowse -> addPosition( 'enabled', 'Aktywny', '', \System::getComboYesNo() );
|
||||
$dbrowse -> addPositionSimple( 'edytuj', '', './?rw=edit' );
|
||||
$dbrowse -> setParam( 'id' );
|
||||
$dbrowse -> addSort( 'id ASC' );
|
||||
$dbrowse -> addLp();
|
||||
$out .= $dbrowse -> draw();
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
public function editLanguage( $id )
|
||||
{
|
||||
$out = \admin\view\PagePanel::show( false, true, true, 'Języki' );
|
||||
|
||||
$dbedit = new \DataEdit( 'pp_langs', 'id', $id );
|
||||
$dbedit -> addPosition( 'name', 'Nazwa', 'label' );
|
||||
$dbedit -> addPosition( 'enabled', 'Aktywny', 'radio' , '' , \System::getComboYesNo() );
|
||||
$out .= $dbedit -> draw();
|
||||
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
?>
|
||||
57
autoload/admin/view/class.Layouts.php
Normal file
57
autoload/admin/view/class.Layouts.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
namespace admin\view;
|
||||
|
||||
class Layouts {
|
||||
|
||||
public static function showLayouts()
|
||||
{
|
||||
$out = \admin\view\PagePanel::show( true, false, false, 'Szablony' );
|
||||
|
||||
$dbrowse = new \DataBrowse( 'pp_layouts' );
|
||||
$dbrowse -> addPosition( 'name', 'Nazwa', '', '', '', 'name' );
|
||||
$dbrowse -> addPosition( 'enabled', 'Aktywny', '', \System::getComboYesNo() );
|
||||
$dbrowse -> addPositionSimple( 'edytuj', '', './?rw=edit' );
|
||||
$dbrowse -> addPositionSimple( 'usuń', '', '', \System::deleteAction() );
|
||||
$dbrowse -> setParam( 'id' );
|
||||
$dbrowse -> addSort( 'name ASC' );
|
||||
$dbrowse -> addLp();
|
||||
$out .= $dbrowse -> draw();
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
public static function drawLayoutEditPages( $pages, $step = 0 )
|
||||
{
|
||||
$tpl = new \Savant3;
|
||||
$tpl -> _pages = $pages;
|
||||
$tpl -> _step = $step;
|
||||
return $tpl -> fetch( 'other/layout-edit-pages' );
|
||||
}
|
||||
|
||||
public static function addLayout()
|
||||
{
|
||||
$out = \admin\view\PagePanel::show( false, true, true, 'Szablony' );
|
||||
|
||||
$tpl = new \Savant3;
|
||||
$tpl -> _rw = 'save_new';
|
||||
$tpl -> _pages = \admin\factory\Layouts::getPagesAssign();
|
||||
$out .= $tpl -> fetch( 'other/layout-edit' );
|
||||
return $out;
|
||||
}
|
||||
|
||||
public static function editLayout( $id )
|
||||
{
|
||||
\System::deleteSessionVar( 'id_menu' );
|
||||
|
||||
$out = \admin\view\PagePanel::show( false, true, true, 'Szablony', 'formularz' , false , false , 'saveLayout()' );
|
||||
|
||||
$tpl = new \Savant3;
|
||||
$tpl -> _rw = 'save';
|
||||
$tpl -> _pages = \admin\factory\Layouts::getPagesAssign( $id );
|
||||
$tpl -> _layout = \admin\factory\Layouts::getLayout( $id, true );
|
||||
$out .= $tpl -> fetch( 'other/layout-edit' );
|
||||
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
?>
|
||||
38
autoload/admin/view/class.Menu.php
Normal file
38
autoload/admin/view/class.Menu.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
namespace admin\view;
|
||||
|
||||
class Menu
|
||||
{
|
||||
public static function showMenu()
|
||||
{
|
||||
$out = \admin\view\PagePanel::show( true, false, false, 'Menu' );
|
||||
|
||||
$dbrowse = new \DataBrowse( 'pp_menu' );
|
||||
$dbrowse -> addPosition( 'name', 'Nazwa', '', '', '', 'name' );
|
||||
$dbrowse -> addPosition( 'enabled', 'Aktywne', './?rw=change-enabled', \System::getComboYesNo() );
|
||||
$dbrowse -> addPosition( 'type', 'Typ', '', \admin\factory\Menu::getMenuType() );
|
||||
$dbrowse -> addPositionSimple( 'edytuj', '', './?rw=edit' );
|
||||
$dbrowse -> addPositionSimple( 'usuń', '', '', \System::deleteAction() );
|
||||
$dbrowse -> setParam( 'id' );
|
||||
$dbrowse -> addSort( 'id ASC' );
|
||||
$dbrowse -> addLp();
|
||||
$out .= $dbrowse -> draw();
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
public static function editMenu( $id = '' )
|
||||
{
|
||||
$id ? $value = 'Zapisz' : $value = 'Dodaj';
|
||||
$out = \admin\view\PagePanel::show( false, $value, true, 'Menu' );
|
||||
|
||||
$dbedit = new \DataEdit( 'pp_menu', 'id', $id );
|
||||
$dbedit -> addPosition( 'name', 'Nazwa', 'text' );
|
||||
$dbedit -> addPosition( 'enabled', 'Aktywne', 'radio', '', \System::getComboYesNo() );
|
||||
$dbedit -> addPosition( 'type', 'Typ', 'combo', '', \admin\factory\Menu::getMenuType() );
|
||||
$out .= $dbedit -> draw();
|
||||
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
?>
|
||||
38
autoload/admin/view/class.Newsletter.php
Normal file
38
autoload/admin/view/class.Newsletter.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
namespace admin\view;
|
||||
|
||||
class Newsletter {
|
||||
|
||||
public function editEmail( $id = '' )
|
||||
{
|
||||
$id ? $value = 'Zapisz' : $value = 'Dodaj';
|
||||
|
||||
$out = \admin\view\PagePanel::show( false, $value, true, 'Newsletter - emaile' );
|
||||
|
||||
$dbedit = new \DataEdit( 'pp_newsletter_emails', 'id', $id );
|
||||
$dbedit -> addPosition( 'email', 'Email', 'text' );
|
||||
$dbedit -> addPosition( 'enabled', 'Aktywny', 'radio', '', \System::getComboYesNo() );
|
||||
$out .= $dbedit -> draw();
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
public function showEmailList()
|
||||
{
|
||||
$out = \admin\view\PagePanel::show( true, false, false, 'Newsletter - emaile' );
|
||||
|
||||
$dbrowse = new \DataBrowse( 'pp_newsletter_emails' );
|
||||
$dbrowse -> addPosition( 'email', 'Email', '', '', '', 'email' );
|
||||
$dbrowse -> addPosition( 'enabled', 'Aktywny', '', \System::getComboYesNo() );
|
||||
$dbrowse -> addPositionSimple( 'edytuj', '', './?rw=edit' );
|
||||
$dbrowse -> addPositionSimple( 'usuń', '', '', \System::deleteAction() );
|
||||
$dbrowse -> setParam( 'id' );
|
||||
$dbrowse -> addSort( 'email ASC' );
|
||||
$dbrowse -> addLp();
|
||||
$dbrowse -> addFiltr( 'email', 'Email' );
|
||||
$dbrowse -> addFiltr( 'enabled', 'Aktywny', \System::getComboYesNo() );
|
||||
$out .= $dbrowse -> draw();
|
||||
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
15
autoload/admin/view/class.Page.php
Normal file
15
autoload/admin/view/class.Page.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
namespace admin\view;
|
||||
|
||||
class Page {
|
||||
|
||||
public static function show()
|
||||
{
|
||||
$tpl = new \Savant3;
|
||||
$tpl -> _content = \admin\controls\Page::getContent();
|
||||
$tpl -> _page_type = \System::getSessionVar( 'page_type' );
|
||||
$tpl -> _alert = \System::getSessionVar( 'alert' );
|
||||
return $tpl -> fetch( 'other/page-main' );
|
||||
}
|
||||
}
|
||||
?>
|
||||
21
autoload/admin/view/class.PagePanel.php
Normal file
21
autoload/admin/view/class.PagePanel.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
namespace admin\view;
|
||||
|
||||
class PagePanel {
|
||||
|
||||
public static function show( $add = false, $save = false, $cancel = false, $title = '', $form = 'formularz', $back = false, $update = false, $save_ajax = false, $delete_ajax = false )
|
||||
{
|
||||
$tpl = new \Savant3();
|
||||
$tpl -> _add = $add;
|
||||
$tpl -> _save = $save;
|
||||
$tpl -> _cancel = $cancel;
|
||||
$tpl -> _id_form = $form;
|
||||
$tpl -> _title = $title;
|
||||
$tpl -> _back = $back;
|
||||
$tpl -> _update = $update;
|
||||
$tpl -> _save_ajax = $save_ajax;
|
||||
$tpl -> _delete_ajax = $delete_ajax;
|
||||
return $tpl -> fetch( 'other/page-panel' );
|
||||
}
|
||||
}
|
||||
?>
|
||||
87
autoload/admin/view/class.Pages.php
Normal file
87
autoload/admin/view/class.Pages.php
Normal file
@@ -0,0 +1,87 @@
|
||||
<?
|
||||
// po poprawkach
|
||||
namespace admin\view;
|
||||
|
||||
class Pages
|
||||
{
|
||||
public static function showAssignedArticles( $id )
|
||||
{
|
||||
$out = \admin\view\PagePanel::show( false, false, true, 'Przypisane artykuły' );
|
||||
|
||||
$tpl = new \Savant3();
|
||||
$tpl -> _articles = \admin\factory\Pages::getAssignedArticles( $id );
|
||||
$out .= $tpl -> fetch( 'pages/page-articles-list' );
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
public static function showPages()
|
||||
{
|
||||
$tpl = new \Savant3;
|
||||
$tpl -> _menu = \admin\factory\Menu::getMenu();
|
||||
return $tpl -> fetch( 'pages/page-definition' );
|
||||
}
|
||||
|
||||
public static function editPage( $id, $menu_id )
|
||||
{
|
||||
$out = \admin\view\PagePanel::show( false, 'Zapisz', true, 'Lista stron' );
|
||||
|
||||
$page = \admin\factory\Pages::getPageParam( $id );
|
||||
|
||||
$tpl = new \Savant3;
|
||||
$tpl -> _id = $id;
|
||||
$tpl -> _page = $page;
|
||||
$tpl -> _rw = 'edit';
|
||||
$tpl -> _menu_id = $menu_id;
|
||||
$tpl -> _parent_id = $page['parent_id'];
|
||||
$tpl -> _menu = \admin\factory\Menu::getMenu();
|
||||
$tpl -> _language = \admin\factory\Pages::getPageParamLanguage( $id );
|
||||
$tpl -> _pages = \admin\factory\Pages::getPages( $menu_id );
|
||||
$tpl -> _page_types = \admin\factory\Pages::getPageTypes();
|
||||
$tpl -> _sort = \admin\factory\Pages::getSortTypes();
|
||||
$tpl -> _layouts = \admin\factory\Layouts::getLayouts();
|
||||
$tpl -> _layout_id = \admin\factory\Pages::getPageLayout( $id );
|
||||
$out .= $tpl -> fetch( 'pages/page-edit' );
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
public static function addPage( $menu_id, $parent_id = 0 )
|
||||
{
|
||||
$out = \admin\view\PagePanel::show( false, 'Dodaj', true, 'Lista stron' );
|
||||
|
||||
$tpl = new \Savant3;
|
||||
$tpl -> _rw = 'add';
|
||||
$tpl -> _menu_id = $menu_id;
|
||||
$tpl -> _parent_id = $parent_id;
|
||||
$tpl -> _language = \language\FLanguage::getLangs();
|
||||
$tpl -> _menu = \admin\factory\Menu::getMenu();
|
||||
$tpl -> _page_types = \admin\factory\Pages::getPageTypes();
|
||||
$tpl -> _pages = \admin\factory\Pages::getPages( $menu_id );
|
||||
$tpl -> _sort = \admin\factory\Pages::getSortTypes();
|
||||
$tpl -> _order = \admin\factory\Pages::selectMaxOrder();
|
||||
$tpl -> _layouts = \admin\factory\Layouts::getLayouts();
|
||||
$out .= $tpl -> fetch( 'pages/page-edit' );
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
public static function drawSubpagesEdit( $pages, $parent_id, $step = 0, $this_id = false )
|
||||
{
|
||||
$tpl = new \Savant3();
|
||||
$tpl -> _pages = $pages;
|
||||
$tpl -> _parent_id = $parent_id;
|
||||
$tpl -> _step = $step;
|
||||
$tpl -> _this_id = $this_id;
|
||||
return $tpl -> fetch( 'pages/page-subpages-edit' );
|
||||
}
|
||||
|
||||
public static function drawSubpages( $pages, $parent_id = 0 )
|
||||
{
|
||||
$tpl = new \Savant3();
|
||||
$tpl -> _pages = $pages;
|
||||
$tpl -> _parent_id = $parent_id;
|
||||
return $tpl -> fetch( 'pages/page-subpages' );
|
||||
}
|
||||
}
|
||||
?>
|
||||
66
autoload/admin/view/class.Restriction.php
Normal file
66
autoload/admin/view/class.Restriction.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?
|
||||
// po poprawkach
|
||||
namespace admin\view;
|
||||
|
||||
class Restriction
|
||||
{
|
||||
public function editBannedEmail( $id = '' )
|
||||
{
|
||||
$id ? $value = 'Zapisz' : $value = 'Dodaj';
|
||||
$out = \admin\view\PagePanel::show( false, $value, true, 'Zbanowane adresy email' );
|
||||
|
||||
$dbedit = new \DataEdit( 'pp_banned_email', 'id', $id );
|
||||
$dbedit -> addPosition( 'email', 'Email', 'text' );
|
||||
$out .= $dbedit -> draw();
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
public function showBannedEmails()
|
||||
{
|
||||
$out = \admin\view\PagePanel::show( 'Dodaj nowy', false, false, 'Zbanowane adresy email' );
|
||||
|
||||
$dbrowse = new \DataBrowse('pp_banned_email');
|
||||
$dbrowse -> addPosition( 'email', 'Email', '', '', '', 'email' );
|
||||
$dbrowse -> addPositionSimple( 'edytuj', '', './?rw=edit' );
|
||||
$dbrowse -> addPositionSimple( 'usuń', '', '', \System::deleteAction() );
|
||||
$dbrowse -> setParam( 'id' );
|
||||
$dbrowse -> addSort( 'email ASC' );
|
||||
$dbrowse -> addLp();
|
||||
$dbrowse -> addFiltr( 'email', 'Email' );
|
||||
$out .= $dbrowse -> draw();
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
public function editBannedLogin( $id = '' )
|
||||
{
|
||||
$id ? $value = 'Zapisz' : $value = 'Dodaj';
|
||||
|
||||
$out = \admin\view\PagePanel::show( false, $value, true, "Zbanowane loginy" );
|
||||
|
||||
$dbedit = new \DataEdit( 'pp_banned_login', 'id', $id );
|
||||
$dbedit -> addPosition( 'login', 'Login', 'text' );
|
||||
$out .= $dbedit -> draw();
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
public function showBannedLogins()
|
||||
{
|
||||
$out = \admin\view\PagePanel::show( 'Dodaj nowy', false, false, "Zbanowane loginy" );
|
||||
|
||||
$dbrowse = new \DataBrowse( 'pp_banned_login' );
|
||||
$dbrowse -> addPosition( 'login', 'Login', '', '', '', 'login' );
|
||||
$dbrowse -> addPositionSimple( 'edytuj', '', './?rw=edit' );
|
||||
$dbrowse -> addPositionSimple( 'usuń', '', '', \System::deleteAction() );
|
||||
$dbrowse -> setParam( 'id' );
|
||||
$dbrowse -> addSort( 'login ASC' );
|
||||
$dbrowse -> addLp();
|
||||
$dbrowse -> addFiltr( 'login', 'Login' );
|
||||
$out .= $dbrowse -> draw();
|
||||
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
?>
|
||||
37
autoload/admin/view/class.SContainers.php
Normal file
37
autoload/admin/view/class.SContainers.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
namespace admin\view;
|
||||
|
||||
class SContainers {
|
||||
|
||||
public function editContainer( $id = '' )
|
||||
{
|
||||
$id ? $value = 'Zapisz' : $value = 'Dodaj';
|
||||
|
||||
$out = \admin\view\PagePanel::show( false, $value, true, 'Zawartość statyczna' );
|
||||
|
||||
$tpl = new \Savant3;
|
||||
if ( $id )
|
||||
$tpl -> _container = \admin\factory\SContainers::getContainer( $id );
|
||||
$tpl -> _languages = \admin\factory\SContainers::getContainerParamLanguage( $id );
|
||||
$out .= $tpl -> fetch( 'scontainers/edit-container' );
|
||||
return $out;
|
||||
}
|
||||
|
||||
public function showContainerList()
|
||||
{
|
||||
$out = \admin\view\PagePanel::show( true, false, false, 'Zawartość statyczna' );
|
||||
|
||||
$dbrowse = new \DataBrowse( 'pp_static_container' );
|
||||
$dbrowse -> addPosition( 'name', 'Nazwa', '', '', '', 'name' );
|
||||
$dbrowse -> addPosition( 'id', 'Użycie', '', "SELECT id, CONCAT( '[KONTENER:', id, ']' ) FROM pp_static_container", '', 'name' );
|
||||
$dbrowse -> addPosition( 'enabled', 'Aktywne', '', \System::getComboYesNo() );
|
||||
$dbrowse -> addPositionSimple( 'edytuj', '', './?rw=edit' );
|
||||
$dbrowse -> addPositionSimple( 'usuń', '', '', \System::deleteAction() );
|
||||
$dbrowse -> setParam( 'id' );
|
||||
$dbrowse -> addSort( 'name ASC' );
|
||||
$dbrowse -> addLp();
|
||||
$out .= $dbrowse -> draw();
|
||||
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
37
autoload/admin/view/class.Settings.php
Normal file
37
autoload/admin/view/class.Settings.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?
|
||||
namespace admin\view;
|
||||
|
||||
class Settings
|
||||
{
|
||||
public static function showSettings()
|
||||
{
|
||||
$out = \admin\view\PagePanel::show( false, true, false, 'Ustawienia' );
|
||||
|
||||
$tpl = new \Savant3;
|
||||
$tpl -> _firm_name = \admin\factory\Settings::getSystemSettings( 'firm_name' );
|
||||
$tpl -> _street = \admin\factory\Settings::getSystemSettings( 'street' );
|
||||
$tpl -> _postal_code = \admin\factory\Settings::getSystemSettings( 'postal_code' );
|
||||
$tpl -> _city = \admin\factory\Settings::getSystemSettings( 'city' );
|
||||
$tpl -> _nip = \admin\factory\Settings::getSystemSettings( 'nip' );
|
||||
$tpl -> _email = \admin\factory\Settings::getSystemSettings( 'email' );
|
||||
$tpl -> _phone = \admin\factory\Settings::getSystemSettings( 'phone' );
|
||||
$tpl -> _account = \admin\factory\Settings::getSystemSettings( 'account' );
|
||||
$tpl -> _person = \admin\factory\Settings::getSystemSettings( 'person' );
|
||||
$tpl -> _fax = \admin\factory\Settings::getSystemSettings( 'fax' );
|
||||
$tpl -> _contact_form = \admin\factory\Settings::getSystemSettings( 'contact_form' );
|
||||
$tpl -> _user_register = \admin\factory\Settings::getSystemSettings( 'user_register' );
|
||||
$tpl -> _admin_email = \admin\factory\Settings::getSystemSettings( 'admin_email' );
|
||||
$tpl -> _email_host = \admin\factory\Settings::getSystemSettings( 'email_host' );
|
||||
$tpl -> _email_port = \admin\factory\Settings::getSystemSettings( 'email_port' );
|
||||
$tpl -> _email_login = \admin\factory\Settings::getSystemSettings( 'email_login' );
|
||||
$tpl -> _email_password = \admin\factory\Settings::getSystemSettings( 'email_password' );
|
||||
$tpl -> _google_map_key = \admin\factory\Settings::getSystemSettings( 'google_map_key' );
|
||||
$tpl -> _register = \admin\factory\Settings::getSystemSettings( 'register' );
|
||||
$tpl -> _facebook_url = \admin\factory\Settings::getSystemSettings( 'facebook_url' );
|
||||
$tpl -> _info = \admin\factory\Settings::getSystemSettings( 'info' );
|
||||
$out .= $tpl -> fetch( 'other/settings' );
|
||||
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
?>
|
||||
90
autoload/admin/view/class.Users.php
Normal file
90
autoload/admin/view/class.Users.php
Normal file
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
namespace admin\view;
|
||||
|
||||
class Users
|
||||
{
|
||||
public static function drawLoginForm()
|
||||
{
|
||||
$tpl = new \Savant3;
|
||||
return $tpl -> fetch( 'other/login-form' );
|
||||
}
|
||||
|
||||
public function editAdmin( $id = '' )
|
||||
{
|
||||
$id ? $value = 'Zapisz': $value = 'Dodaj';
|
||||
|
||||
$out = \admin\view\PagePanel::show( false, $value, true, 'Administratorzy' );
|
||||
|
||||
$dbedit = new \DataEdit( 'pp_users', 'id', $id );
|
||||
$dbedit -> addPosition('login', 'Login', 'text');
|
||||
$dbedit -> addPosition('name', 'Imię', 'text');
|
||||
$dbedit -> addPosition('surname', 'Nazwisko', 'text');
|
||||
$dbedit -> addPosition('enabled', 'Aktywny', 'radio', '', \System::getComboYesNo());
|
||||
$dbedit -> addPositionHidden('admin', '1');
|
||||
$dbedit -> addPositionPassword();
|
||||
$out .= $dbedit->draw();
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
public function showAdmins()
|
||||
{
|
||||
$out = \admin\view\PagePanel::show( true, false, false, 'Administratorzy' );
|
||||
|
||||
$dbrowse = new \DataBrowse( 'pp_users', 'admin = "1" AND login != "Vampirius"' );
|
||||
$dbrowse -> addPosition( 'login', 'Login', '', '', '', 'login' );
|
||||
$dbrowse -> addPosition( 'name', 'Imię', '', '', '', 'name' );
|
||||
$dbrowse -> addPosition( 'surname', 'Nazwisko', '', '', '', 'surname' );
|
||||
$dbrowse -> addPosition( 'enabled', 'Aktywny', '', \System::getComboYesNo() );
|
||||
$dbrowse -> addPositionSimple( 'edytuj', '', './?rw=edit' );
|
||||
$dbrowse -> addPositionSimple( 'usuń', '', '', \System::deleteAction() );
|
||||
$dbrowse -> setParam( 'id' );
|
||||
$dbrowse -> addSort( 'id ASC' );
|
||||
$dbrowse -> addLp();
|
||||
$dbrowse -> addFiltr( 'login', 'Login' );
|
||||
$dbrowse -> addFiltr( 'enabled', 'Aktywny', \System::getComboYesNo() );
|
||||
$out .= $dbrowse -> draw();
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
public function showUsers()
|
||||
{
|
||||
$out = \admin\view\PagePanel::show( true, false, false, 'Użytkownicy' );
|
||||
|
||||
$dbrowse = new \DataBrowse( 'pp_users', 'admin = "0"' );
|
||||
$dbrowse -> addPosition( 'login', 'Login', '', '', '', 'login' );
|
||||
$dbrowse -> addPosition( 'name', 'Imię', '', '', '', 'name' );
|
||||
$dbrowse -> addPosition( 'surname', 'Nazwisko', '', '', '', 'surname' );
|
||||
$dbrowse -> addPosition( 'enabled', 'Aktywny', '', \System::getComboYesNo() );
|
||||
$dbrowse -> addPositionSimple( 'edytuj', '', './?rw=edit' );
|
||||
$dbrowse -> addPositionSimple( 'usuń', '', '', \System::deleteAction() );
|
||||
$dbrowse -> setParam( 'id' );
|
||||
$dbrowse -> addSort( 'id ASC' );
|
||||
$dbrowse -> addLp();
|
||||
$dbrowse -> addFiltr( 'login', 'Login' );
|
||||
$dbrowse -> addFiltr( 'enabled', 'Aktywny', \System::getComboYesNo() );
|
||||
$out .= $dbrowse -> draw();
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
public function editUser( $id = '' )
|
||||
{
|
||||
$id ? $value = 'Zapisz' : $value = 'Dodaj';
|
||||
|
||||
$out = \admin\view\PagePanel::show( false, $value, true, 'Użytkownicy' );
|
||||
|
||||
$dbedit = new \DataEdit( 'pp_users', 'id', $id );
|
||||
$dbedit -> addPosition( 'login', 'Login', 'text' );
|
||||
$dbedit -> addPosition( 'name', 'Imię', 'text' );
|
||||
$dbedit -> addPosition( 'surname', 'Nazwisko', 'text' );
|
||||
$dbedit -> addPosition( 'enabled', 'Aktywny', 'radio', '', \System::getComboYesNo() );
|
||||
$dbedit -> addPositionHidden( 'admin', '0' );
|
||||
$dbedit -> addPositionPassword();
|
||||
$out .= $dbedit -> draw();
|
||||
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
?>
|
||||
488
autoload/article/class.Article.php
Normal file
488
autoload/article/class.Article.php
Normal file
@@ -0,0 +1,488 @@
|
||||
<?php
|
||||
namespace article;
|
||||
|
||||
class Article
|
||||
{
|
||||
public $_values;
|
||||
|
||||
public function __construct( $id )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'SELECT * FROM pp_articles WHERE id = :id' );
|
||||
$query -> bindValue( ':id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch( \PDO::FETCH_ASSOC ) )
|
||||
{
|
||||
foreach ( $row as $key => $val )
|
||||
$this -> _values[$key] = $val;
|
||||
}
|
||||
$query -> closeCursor();
|
||||
|
||||
$query = $db -> prepare( 'SELECT title, text, meta_description, meta_keywords, seo_link FROM pp_articles_langs WHERE article_id = :article_id AND lang_id = :lang_id' );
|
||||
$query -> bindValue( ':article_id', $id, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':lang_id', \System::getSessionVar( 'current_lang' ), \PDO::PARAM_STR );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch( \PDO::FETCH_ASSOC ) )
|
||||
{
|
||||
foreach ( $row as $key => $val )
|
||||
$this -> _values[$key] = $val;
|
||||
}
|
||||
$query -> closeCursor();
|
||||
|
||||
$query = $db -> prepare( 'SELECT * FROM pp_articles_img WHERE id_article = :id_article' );
|
||||
$query -> bindValue( ':id_article', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
$images[] = $row;
|
||||
$query -> closeCursor();
|
||||
|
||||
$this -> _values['images'] = $images;
|
||||
|
||||
$query = $db -> prepare( 'SELECT * FROM pp_articles_file WHERE id_article = :id_article' );
|
||||
$query -> bindValue( ':id_article', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
$files[] = $row;
|
||||
$query -> closeCursor();
|
||||
|
||||
$this -> _values['files'] = $files;
|
||||
|
||||
$query = $db -> prepare( 'SELECT * FROM pp_articles_comments WHERE article_id = :article_id ORDER BY date_add ASC' );
|
||||
$query -> bindValue( ':article_id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
$comments[] = $row;
|
||||
$query -> closeCursor();
|
||||
|
||||
$this -> _values['comments'] = $comments;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getImg()
|
||||
{
|
||||
global $db;
|
||||
|
||||
$src = '';
|
||||
|
||||
if ( $this -> _values['thumbnail'] )
|
||||
return $this -> _values['thumbnail'];
|
||||
|
||||
$regex_img = "|<[\s\v]*img[\s\v]([^>]*[^>]*)>|Ui";
|
||||
preg_match_all( $regex_img, $this -> _values['text'], $matches_img );
|
||||
$count_img = count($matches_img[0]);
|
||||
if ( $count_img )
|
||||
{
|
||||
if ( @$matches_img[1][0] )
|
||||
{
|
||||
$inline_params = $matches_img[1][0];
|
||||
$asrc = array();
|
||||
preg_match( "#src=\"(.*?)\"#s", $inline_params, $asrc );
|
||||
if ( isset($asrc[1]) )
|
||||
$src = trim($asrc[1]);
|
||||
else
|
||||
$src = "";
|
||||
$syn = substr($src,0,1);
|
||||
if ( $syn === "/" or $syn === "\\" )
|
||||
$src = substr($src,1,99999);
|
||||
$syn = substr($src,0,3);
|
||||
if ( $syn == "../" )
|
||||
$src = substr($src,3,99999);
|
||||
$syn = substr($src,0,7);
|
||||
if ( $syn == "example" )
|
||||
$src = substr($src,8,99999);
|
||||
}
|
||||
}
|
||||
|
||||
if ( !$src )
|
||||
{
|
||||
$image = false;
|
||||
if ( strpos( $this -> _values['text'], "{galeria}" ) !== false )
|
||||
{
|
||||
$text = explode( "{galeria}", $this -> _values['text'] );
|
||||
for ( $i = 1; $i < count( $text ); $i++ )
|
||||
{
|
||||
$temp = explode( "{/galeria}", $text[$i] );
|
||||
$path = $temp[0];
|
||||
if ( $path != "" && is_dir( $path ) )
|
||||
{
|
||||
@$fh = opendir($path);
|
||||
while ( false !== ( $filename = @readdir($fh) ) && !$image )
|
||||
{
|
||||
if ( $filename == "." || $filename == ".." ) continue;
|
||||
if ( file_exists($path.$filename) )
|
||||
{
|
||||
$src = $path.$filename;
|
||||
$image = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( !$src )
|
||||
{
|
||||
$query = $db -> prepare( 'SELECT src FROM pp_articles_img WHERE id_article = :id_article ORDER BY id ASC LIMIT 1' );
|
||||
$query -> bindValue( ':id_article', $this -> _values['id'], \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
$src = $row['src'];
|
||||
$query -> closeCursor();
|
||||
}
|
||||
|
||||
return $src;
|
||||
}
|
||||
|
||||
public function getModifyText( $entry = false )
|
||||
{
|
||||
if ( $entry )
|
||||
$this -> removeImages();
|
||||
if ( !$entry )
|
||||
{
|
||||
$this -> drawGallery();
|
||||
$this -> drawShadowBox();
|
||||
}
|
||||
$this -> includePHP( $entry );
|
||||
$this -> drawSlider( $entry );
|
||||
$this -> getMap();
|
||||
return $this -> _values['text'];
|
||||
}
|
||||
|
||||
public function getMap()
|
||||
{
|
||||
$out = '';
|
||||
if ( strpos( $this -> _values['text'], "{mapa}" ) !== false )
|
||||
{
|
||||
$text = explode( "{mapa}", $this -> _values['text'] );
|
||||
$before = $text[0];
|
||||
|
||||
for ( $i = 1; $i < count( $text ); $i++ )
|
||||
{
|
||||
$temp = explode( "{/mapa}", $text[$i] );
|
||||
$settings_temp = $temp[0];
|
||||
|
||||
$settings = explode("|",$settings_temp);
|
||||
for ( $j = 0; $j < count( $settings ); $j++ )
|
||||
{
|
||||
$params = explode(":",$settings[$j]);
|
||||
if ( trim($params[0]) == "adres" )
|
||||
$adress = $params[1];
|
||||
else if ( trim($params[0]) == "szerokosc" )
|
||||
$width = $params[1];
|
||||
else if ( trim($params[0]) == "wysokosc" )
|
||||
$height = $params[1];
|
||||
else if ( trim($params[0]) == "x_coord" )
|
||||
$x_coord = \System::saveString($params[1]);
|
||||
else if ( trim($params[0]) == "y_coord" )
|
||||
$y_coord = \System::saveString($params[1]);
|
||||
else if ( trim($params[0]) == "zoom" )
|
||||
$zoom = (int)$params[1];
|
||||
}
|
||||
|
||||
$id = rand(0,10000000000000);
|
||||
|
||||
if ( !isset( $zoom ) || !$zoom )
|
||||
$zoom = 13;
|
||||
|
||||
if ( $adress != "" && $adress != " " )
|
||||
{
|
||||
if ( $width == "" )
|
||||
$width = 400;
|
||||
if ( $height == "" )
|
||||
$height = 250;
|
||||
|
||||
$tpl = new \Savant3;
|
||||
$tpl -> _google_map_key = \admin\factory\Settings::getSystemSettings( 'google_map_key' );
|
||||
$tpl -> _adress = trim( strip_tags( $adress ) );
|
||||
$tpl -> _zoom = (int)$zoom;
|
||||
$tpl -> _width = (int)$width;
|
||||
$tpl -> _height = (int)$height;
|
||||
$tpl -> _id = $id;
|
||||
$out .= $tpl -> fetch( 'articles/article-map' );
|
||||
}
|
||||
else if ( $x_coord && $y_coord )
|
||||
{
|
||||
$tpl = new \Savant3;
|
||||
$tpl -> _google_map_key = \admin\factory\Settings::getSystemSettings( 'google_map_key' );
|
||||
$tpl -> _x_coord = $x_coord;
|
||||
$tpl -> _y_coord = $y_coord;
|
||||
$tpl -> _zoom = (int)$zoom;
|
||||
$tpl -> _width = (int)$width;
|
||||
$tpl -> _height = (int)$height;
|
||||
$tpl -> _id = $id;
|
||||
$out .= $tpl -> fetch( 'articles/article-map' );
|
||||
}
|
||||
$out .= $temp[1];
|
||||
}
|
||||
$this -> _values['text'] = $before . $out;
|
||||
}
|
||||
}
|
||||
|
||||
public function drawSlider( $entry )
|
||||
{
|
||||
$out = '';
|
||||
|
||||
if ( strpos( $this -> _values['text'] , '{slider}' ) !== false )
|
||||
{
|
||||
$text = explode( '{slider}' , $this -> _values['text'] );
|
||||
$before = $text[0];
|
||||
for ( $i = 1; $i < count( $text ); $i++ )
|
||||
{
|
||||
$temp = explode( '{/slider}' , $text[$i] );
|
||||
$path = $temp[0];
|
||||
if ( $path && !$entry && is_dir( $path ) )
|
||||
{
|
||||
$fh = @opendir($path);
|
||||
while ( false !== ( $filename = @readdir($fh) ) )
|
||||
{
|
||||
if ( $filename == "." || $filename == ".." ) continue;
|
||||
if ( file_exists($path.$filename) )
|
||||
{
|
||||
$nazwa = pathinfo( $path . $filename );
|
||||
$pliki[$nazwa['basename']] = $nazwa['extension'];
|
||||
}
|
||||
}
|
||||
if ( is_array( $pliki ) ) ksort($pliki);
|
||||
if ( is_array( $pliki ) ) foreach ( $pliki as $key => $val )
|
||||
{
|
||||
$img['src'] = $path . $key;
|
||||
$images[] = $img;
|
||||
}
|
||||
$out .= \article\VArticle::drawSlider( $this -> _id , $images );
|
||||
}
|
||||
$out .= $temp[1];
|
||||
}
|
||||
$this -> _values['text'] = $before . $out;
|
||||
}
|
||||
}
|
||||
|
||||
public function includePHP( $entry )
|
||||
{
|
||||
$out = '';
|
||||
|
||||
if ( strpos( $this -> _values['text'] , '{include_php}' ) !== false )
|
||||
{
|
||||
$text = explode( '{include_php}' , $this -> _values['text'] );
|
||||
$before = $text[0];
|
||||
for ( $i = 1; $i < count( $text ); $i++ )
|
||||
{
|
||||
$temp = explode( '{/include_php}' , $text[$i] );
|
||||
$path = $temp[0];
|
||||
if ( $path && !$entry )
|
||||
{
|
||||
if ( file_exists( $path ) )
|
||||
{
|
||||
ob_start();
|
||||
include( $path );
|
||||
$out .= ob_get_contents();
|
||||
ob_end_clean();
|
||||
}
|
||||
}
|
||||
$out .= $temp[1];
|
||||
}
|
||||
$this -> _values['text'] = $before . $out;
|
||||
}
|
||||
}
|
||||
|
||||
public function drawGallery()
|
||||
{
|
||||
$out = '';
|
||||
|
||||
if ( strpos( $this -> _values['text'] , '{galeria}' ) !== false )
|
||||
{
|
||||
$text = explode( '{galeria}' , $this -> _values['text'] );
|
||||
$before = $text[0];
|
||||
for ( $i = 1; $i < count( $text ); $i++ )
|
||||
{
|
||||
if ( trim( strip_tags( $text[$i] ) ) != '' )
|
||||
{
|
||||
$images = '';
|
||||
$temp = explode( '{/galeria}' , $text[$i] );
|
||||
$path = strip_tags( $temp[0] );
|
||||
|
||||
if ( isset( $path ) && is_dir( $path ) && $path != '' )
|
||||
{
|
||||
$fh = @opendir($path);
|
||||
while ( false !== ( $filename = @readdir($fh) ) )
|
||||
{
|
||||
if ( $filename == "." || $filename == ".." ) continue;
|
||||
if ( file_exists($path.$filename) )
|
||||
{
|
||||
$nazwa = pathinfo( $path . $filename );
|
||||
$pliki[$nazwa['basename']] = $nazwa['extension'];
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( isset( $pliki ) && is_array( $pliki ) )
|
||||
ksort($pliki);
|
||||
if ( isset( $pliki ) && is_array( $pliki ) ) foreach ( $pliki as $key => $val )
|
||||
{
|
||||
$img['src'] = $path . $key;
|
||||
$images[] = $img;
|
||||
}
|
||||
$out .= \article\VArticle::drawGallery( $this -> _values['id'] , $images );
|
||||
if ( isset( $temp[1] ) )
|
||||
$out .= $temp[1];
|
||||
}
|
||||
}
|
||||
$this -> _values['text'] = $before . $out;
|
||||
}
|
||||
}
|
||||
|
||||
public function removeImages()
|
||||
{
|
||||
$out = '';
|
||||
$regex_img = "|<[\s\v]*img[\s\v]([^>]*[^>]*)>|Ui";
|
||||
|
||||
preg_match_all( $regex_img, $this -> _values['text'], $matches_img );
|
||||
$count_img = count( $matches_img[0] );
|
||||
if ( $count_img )
|
||||
{
|
||||
for ( $i = 0; $i < $count_img; $i++ )
|
||||
{
|
||||
if ( @$matches_img[1][$i] )
|
||||
{
|
||||
$this -> _values['text'] = str_replace( $matches_img[0][$i] , '' , $this -> _values['text'] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( strpos( $this -> _values['text'] , '{galeria}' ) !== false )
|
||||
{
|
||||
$text = explode( '{galeria}' , $this -> _values['text'] );
|
||||
$before = $text[0];
|
||||
for ( $i = 1; $i < count( $text ); $i++ )
|
||||
{
|
||||
$temp = explode( '{/galeria}' , $text[$i] );
|
||||
$out .= $temp[1];
|
||||
}
|
||||
$this -> _values['text'] = $before . $out;
|
||||
}
|
||||
}
|
||||
|
||||
public function drawShadowBox()
|
||||
{
|
||||
$regex_img = "|<[\s\v]*img[\s\v]([^>]*[^>]*)>|Ui";
|
||||
preg_match_all( $regex_img, $this -> _values['text'], $matches_img);
|
||||
$count_img = count( $matches_img[0] );
|
||||
if ( $count_img )
|
||||
{
|
||||
for ( $i=0; $i < $count_img; $i++ )
|
||||
{
|
||||
if (@$matches_img[1][$i])
|
||||
{
|
||||
$inline_params = $matches_img[1][$i];
|
||||
$aclass = array();
|
||||
preg_match( "#class=\"(.*?)\"#s", $inline_params, $aclass );
|
||||
if ( isset($aclass[1]) )
|
||||
$individ_class = trim($aclass[1]);
|
||||
else
|
||||
$individ_class="";
|
||||
$awidth = array();
|
||||
preg_match( "#width:(.*?);#s", $inline_params, $awidth );
|
||||
if ( isset($awidth[1]) )
|
||||
$individ_width = trim($awidth[1]);
|
||||
else
|
||||
$individ_width="";
|
||||
$aheight = array();
|
||||
preg_match( "#height:(.*?);#s", $inline_params, $aheight );
|
||||
if ( isset($aheight[1]) )
|
||||
$individ_height = trim($aheight[1]);
|
||||
else
|
||||
$individ_height="";
|
||||
$aborder = array();
|
||||
preg_match( "#border:(.*?);#s", $inline_params, $aborder );
|
||||
if ( isset($aborder[0]) )
|
||||
$individ_border = trim($aborder[0]);
|
||||
else
|
||||
$individ_border ="";
|
||||
$amagin = array();
|
||||
preg_match( "#margin:(.*?);#s", $inline_params, $amagin );
|
||||
if ( isset($amagin[0]) )
|
||||
$individ_margin = trim($amagin[0]);
|
||||
else
|
||||
$individ_margin ="";
|
||||
$amaginl = array();
|
||||
preg_match( "#margin-left:(.*?);#s", $inline_params, $amaginl );
|
||||
if ( isset($amaginl[0]) )
|
||||
$individ_marginl = trim($amaginl[0]);
|
||||
else
|
||||
$individ_marginl ="";
|
||||
$amaginr = array();
|
||||
preg_match( "#margin-right:(.*?);#s", $inline_params, $amaginr );
|
||||
if ( isset($amaginr[0]) )
|
||||
$individ_marginr = trim($amaginr[0]);
|
||||
else
|
||||
$individ_marginr ="";
|
||||
$amagint = array();
|
||||
preg_match( "#margin-top:(.*?);#s", $inline_params, $amagint );
|
||||
if ( isset($amagint[0]) )
|
||||
$individ_margint = trim($amagint[0]);
|
||||
else
|
||||
$individ_margint ="";
|
||||
$amaginb = array();
|
||||
preg_match( "#margin-bottom:(.*?);#s", $inline_params, $amaginb );
|
||||
if ( isset($amaginb[0]) )
|
||||
$individ_marginb = trim($amaginb[0]);
|
||||
else
|
||||
$individ_marginb ="";
|
||||
$afloat = array();
|
||||
preg_match( "#float:(.*?);#s", $inline_params, $afloat );
|
||||
if ( isset($afloat[0]) )
|
||||
$individ_afloat = trim($afloat[0]);
|
||||
else
|
||||
$individ_afloat ="";
|
||||
$asrc = array();
|
||||
preg_match( "#src=\"(.*?)\"#s", $inline_params, $asrc );
|
||||
if ( isset($asrc[1]) )
|
||||
$src = trim($asrc[1]);
|
||||
else
|
||||
$src = "";
|
||||
$syn = substr($src,0,1);
|
||||
if ( $syn === "/" or $syn === "\\" )
|
||||
$src = substr($src,1,99999);
|
||||
$syn = substr($src,0,3);
|
||||
if ( $syn == "../" )
|
||||
$src = substr($src,3,99999);
|
||||
$syn = substr($src,0,7);
|
||||
if ( $syn == "example" )
|
||||
$src = substr($src,8,99999);
|
||||
|
||||
if ( file_exists($src) )
|
||||
{
|
||||
$check = GetImageSize($src);
|
||||
$width = $check[0];
|
||||
$height = $check[1];
|
||||
if ( ( $width != (int)$individ_width || $height != (int)$individ_height ) && $individ_class != 'noshadow' )
|
||||
{
|
||||
$out = "<a href='" . $src . "' class='fancybox-buttons' rel='" . $this -> _values['id'] . "'>";
|
||||
$out .= "<img class='" . $individ_class . "' src='" . $src . "'
|
||||
style='
|
||||
width:" . $individ_width . ";
|
||||
height:" . $individ_height . ";
|
||||
" . $individ_border . "
|
||||
" . $individ_margin . "
|
||||
" . $individ_marginr . "
|
||||
" . $individ_marginl . "
|
||||
" . $individ_margint . "
|
||||
" . $individ_marginb . "
|
||||
" . $individ_afloat . "'>";
|
||||
$out .= "</a>";
|
||||
$this -> _values['text'] = str_replace( $matches_img[0][$i], $out , $this -> _values['text'] );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function drawPrint()
|
||||
{
|
||||
$out = $this -> _values['title'] . ", " . date( "d/m/Y H:i", strtotime( $this -> _values['date_modify'] ) );
|
||||
$out .= $this -> getModifyText( false );
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
?>
|
||||
274
autoload/article/class.FArticle.php
Normal file
274
autoload/article/class.FArticle.php
Normal file
@@ -0,0 +1,274 @@
|
||||
<?php
|
||||
namespace article;
|
||||
|
||||
class FArticle {
|
||||
|
||||
public function addComment( $article_id, $author, $text, $captcha_code, $check )
|
||||
{
|
||||
global $db, $securimage, $lang;
|
||||
|
||||
if ( !$article_id || !$author || !$text || \System::getSessionVar( 'check' ) == $check || !$securimage -> check( $captcha_code ) )
|
||||
return false;
|
||||
|
||||
$query = $db -> prepare( 'INSERT INTO pp_articles_comments ( article_id, author, text ) VALUES ( :article_id, :author, :text )' );
|
||||
$query -> bindValue( ':article_id', $article_id, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':author', '~' . $author, \PDO::PARAM_STR );
|
||||
$query -> bindValue( ':text', $text, \PDO::PARAM_STR );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() )
|
||||
return \System::setAlert( $lang -> getTrans( 'T_KOMENTARZ_ZOSTAL_DODANY' ) );
|
||||
$query -> closeCursor();
|
||||
return false;
|
||||
}
|
||||
|
||||
public function isArticleOnlyForLogged( $id )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'SELECT pp.id FROM pp_articles_pages AS pap, pp_pages AS pp WHERE pp.id = pap.page_id AND article_id = :article_id AND only_for_logged = 1' );
|
||||
$query -> bindValue( ':article_id', $id, \PDO::PARAM_STR );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
return true;
|
||||
$query -> closeCursor();
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getArticleLayoutId( $id )
|
||||
{
|
||||
global $db, $config, $cache;
|
||||
|
||||
$key = 'getArticleLayoutId:' . $id;
|
||||
if ( !$layout = $cache -> fetch( $key ) )
|
||||
{
|
||||
$query = $db -> prepare( 'SELECT id_layout FROM pp_articles WHERE id = :id' );
|
||||
$query -> bindValue( ':id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
$layout = $row[0];
|
||||
$query -> closeCursor();
|
||||
$cache -> store( $key, $layout, $config['cache_expire_long'] );
|
||||
}
|
||||
|
||||
if ( !$layout )
|
||||
{
|
||||
$query = $db -> query( 'SELECT id FROM pp_layouts WHERE enabled = 1' );
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
$layout = $row[0];
|
||||
$query -> closeCursor();
|
||||
$cache -> store( $key, $layout, $config['cache_expire_long'] );
|
||||
}
|
||||
return $layout;
|
||||
}
|
||||
|
||||
public function searchArtileByTextCount( $text )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$text = \System::saveString( $text, true );
|
||||
|
||||
$query = $db -> query( 'SELECT COUNT(DISTINCT(article_id)) FROM pp_articles_langs WHERE ( LOWER( title ) LIKE "%' . \System::saveString( $text ) . '%" OR LOWER( text ) LIKE "%' . \System::saveString( $text ) . '%" ) AND article_id IN ( SELECT id FROM pp_articles WHERE enabled = 1 AND archive = 0 ) GROUP BY article_id' );
|
||||
return $query -> rowCount();
|
||||
}
|
||||
|
||||
public function searchArtileByText( $text, $from, $limit )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> query( 'SELECT article_id FROM pp_articles_langs WHERE ( LOWER( title ) LIKE "%' . \System::saveString( $text ) . '%" OR LOWER( text ) LIKE "%' . \System::saveString( $text ) . '%" ) AND article_id IN ( SELECT id FROM pp_articles WHERE enabled = 1 AND archive = 0 ) GROUP BY article_id ORDER BY version DESC LIMIT ' . $from . ',' . $limit );
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
$art = \article\FArticle::loadArticle( $row['article_id'] );
|
||||
$articles[] = $art;
|
||||
}
|
||||
return $articles;
|
||||
}
|
||||
|
||||
public function getDescription( $id )
|
||||
{
|
||||
global $db, $config, $cache;
|
||||
|
||||
$current_lang = \System::getSessionVar( 'current_lang' );
|
||||
|
||||
$sKey = 'getDescription:' . $id . ':' . $current_lang;
|
||||
|
||||
if ( !$sDescription = $cache -> fetch( $sKey ) )
|
||||
{
|
||||
$query = $db -> prepare( 'SELECT meta_description FROM pp_articles_langs WHERE article_id = :article_id AND lang_id = :lang_id' );
|
||||
$query -> bindValue( ':article_id', $id, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':lang_id', $current_lang, \PDO::PARAM_STR );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
$sDescription = $row['meta_description'];
|
||||
$query -> closeCursor();
|
||||
$cache -> store( $sKey , $sDescription , $config['cache_expire_long'] );
|
||||
}
|
||||
return $sDescription;
|
||||
}
|
||||
|
||||
public function getArticleTitle( $id )
|
||||
{
|
||||
global $db, $config, $cache;
|
||||
|
||||
$current_lang = \System::getSessionVar( 'current_lang' );
|
||||
|
||||
$key = 'getArticleTitle:' . $id . ':' . $current_lang;
|
||||
|
||||
if ( !$title = $cache -> fetch( $key ) )
|
||||
{
|
||||
$query = $db -> prepare( 'SELECT title FROM pp_articles_langs WHERE article_id = :article_id AND lang_id = :lang_id' );
|
||||
$query -> bindValue( ':article_id', $id, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':lang_id', $current_lang, \PDO::PARAM_STR );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
$title = $row['title'];
|
||||
$query -> closeCursor();
|
||||
$cache -> store( $key, $title, $config['cache_expire_long'] );
|
||||
}
|
||||
return $title;
|
||||
}
|
||||
|
||||
public function getKeywords( $id )
|
||||
{
|
||||
global $db, $config, $cache;
|
||||
|
||||
$current_lang = \System::getSessionVar( 'current_lang' );
|
||||
|
||||
$key = 'getKeywords:' . $id . ':' . $current_lang;
|
||||
|
||||
if ( !$keywords = $cache -> fetch( $key ) )
|
||||
{
|
||||
$query = $db -> prepare( 'SELECT meta_keywords FROM pp_articles_langs WHERE article_id = :article_id AND lang_id = :lang_id' );
|
||||
$query -> bindValue( ':article_id', $id, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':lang_id', $current_lang , \PDO::PARAM_STR );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
$keywords = $row['meta_keywords'];
|
||||
$query -> closeCursor();
|
||||
$cache -> store( $key, $keywords, $config['cache_expire_long'] );
|
||||
}
|
||||
return $keywords;
|
||||
}
|
||||
|
||||
public function loadArticleVersion( $version_id )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'SELECT article_id FROM pp_articles_langs WHERE id = :id' );
|
||||
$query -> bindValue( ':id', $version_id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
$article_id = $row[0];
|
||||
$query -> closeCursor();
|
||||
|
||||
$article = new \article\Article;
|
||||
|
||||
$query = $db -> prepare( 'SELECT * FROM pp_articles WHERE id = :id' );
|
||||
$query -> bindValue( ':id', $article_id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
$article -> set_id( $article_id );
|
||||
$article -> set_date_add( $row['date_add'] );
|
||||
$article -> set_date_modify( $row['date_modify'] );
|
||||
$article -> set_print_enabled( $row['print'] );
|
||||
$article -> set_show_date( $row['show_date'] );
|
||||
$article -> set_show_title( $row['show_title'] );
|
||||
$article -> set_show_author( $row['show_author'] );
|
||||
$article -> set_author( $row['author'] );
|
||||
$article -> set_keep_archive( $row['keep_archive'] );
|
||||
|
||||
$data = array(
|
||||
'table' => 'pp_articles_langs',
|
||||
'fields' => '',
|
||||
'condition' => '',
|
||||
'order' => '',
|
||||
'limit' => 1
|
||||
);
|
||||
$query2 = $db -> prepare( 'SELECT title, text, meta_description, meta_keywords FROM pp_articles_langs WHERE id = :id AND lang_id = "pl" ORDER BY version DESC LIMIT 1' );
|
||||
$query2 -> bindValue( ':id', $version_id, \PDO::PARAM_INT );
|
||||
$query2 -> execute();
|
||||
if ( $query2 -> rowCount() ) while ( $row2 = $query2 -> fetch() )
|
||||
{
|
||||
$article -> set_title( $row2['title'] );
|
||||
$article -> set_text( $row2['text'] );
|
||||
$article -> set_meta_description( $row2['meta_description'] );
|
||||
$article -> set_meta_keywords( $row2['meta_keywords'] );
|
||||
}
|
||||
$query2 -> closeCursor();
|
||||
}
|
||||
$query -> closeCursor();
|
||||
|
||||
return $article;
|
||||
}
|
||||
|
||||
public static function loadArticle( $id )
|
||||
{
|
||||
return new \article\Article( $id );
|
||||
}
|
||||
|
||||
public static function getArticles( $from, $site_id = null )
|
||||
{
|
||||
global $site, $db;
|
||||
|
||||
if ( $site_id )
|
||||
{
|
||||
$site_tmp_id = $site -> _values['id'];
|
||||
$site = new \site\Site( $site_id );
|
||||
$site -> _values['article_number'] = 6;
|
||||
}
|
||||
|
||||
if ( $site -> _values['id_sort_type'] == 1 )
|
||||
$order_by = "date_add DESC ";
|
||||
else if ( $site -> _values['id_sort_type'] == 2 )
|
||||
$order_by = "date_modify DESC";
|
||||
else
|
||||
$order_by = 'o ASC';
|
||||
|
||||
$sql = 'SELECT
|
||||
article_id
|
||||
FROM
|
||||
pp_articles_pages as pap, pp_articles as pa
|
||||
WHERE
|
||||
page_id = :page_id AND article_id = pa.id AND pa.enabled = 1 AND archive = 0
|
||||
GROUP BY
|
||||
article_id
|
||||
ORDER BY
|
||||
' . $order_by . '
|
||||
LIMIT
|
||||
' . $from . ',' . $site -> _values['article_number'];
|
||||
$query = $db -> prepare( $sql );
|
||||
$query -> bindValue( ':page_id', $site -> _values['id'], \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
$art = \article\FArticle::loadArticle( $row['article_id'] );
|
||||
$articles[] = $art;
|
||||
}
|
||||
|
||||
if ( $site_id )
|
||||
$site = new \site\Site( $site_tmp_id );
|
||||
|
||||
return $articles;
|
||||
}
|
||||
|
||||
public static function getCountArticles()
|
||||
{
|
||||
global $site, $db, $cache, $config;
|
||||
|
||||
$key = 'getCountArticles:' . $site -> _values['id'];
|
||||
if ( !$articles = $cache -> fetch( $key ) )
|
||||
{
|
||||
$query = $db -> prepare( 'SELECT COUNT( 0 ) FROM pp_articles_pages as pap , pp_articles as pa WHERE page_id = :page_id AND article_id = pa.id AND pa.enabled = 1 AND archive = 0' );
|
||||
$query -> bindValue( ':page_id', $site -> _values['id'], \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
$articles = $row[0];
|
||||
$query -> closeCursor();
|
||||
|
||||
$cache -> store( $key, $articles, 'l' );
|
||||
}
|
||||
return $articles;
|
||||
}
|
||||
}
|
||||
?>
|
||||
76
autoload/article/class.VArticle.php
Normal file
76
autoload/article/class.VArticle.php
Normal file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
namespace article;
|
||||
|
||||
class VArticle
|
||||
{
|
||||
public function drawArticleListStatic( $id )
|
||||
{
|
||||
$tpl = new \Savant3;
|
||||
$tpl -> _id = $id;
|
||||
$tpl -> _site = new \site\Site( $id );
|
||||
$tpl -> _articles = \article\FArticle::getArticles( 0, $id );
|
||||
return $tpl -> fetch( 'articles/articles-list-static' );
|
||||
}
|
||||
|
||||
public function drawListArticles( $articles )
|
||||
{
|
||||
$tpl = new \Savant3;
|
||||
$tpl -> _articles = $articles;
|
||||
return $tpl -> fetch( 'articles/articles-list' );
|
||||
}
|
||||
|
||||
public function drawMiniatureArticles( $articles )
|
||||
{
|
||||
$tpl = new \Savant3;
|
||||
$tpl -> _articles = $articles;
|
||||
return $tpl -> fetch( 'articles/articles-miniature' );
|
||||
}
|
||||
|
||||
public function drawSlider( $article_id, $images )
|
||||
{
|
||||
$tpl = new \Savant3;
|
||||
$tpl -> _article_id = $article_id;
|
||||
$tpl -> _images = $images;
|
||||
return $tpl -> fetch( 'articles/article-slider' );
|
||||
}
|
||||
|
||||
public function draw( $id )
|
||||
{
|
||||
global $user;
|
||||
|
||||
if ( \article\FArticle::isArticleOnlyForLogged( $id ) && !$user )
|
||||
return \user\VUser::drawLoginForm();
|
||||
|
||||
$article = \article\FArticle::loadArticle( $id );
|
||||
|
||||
if ( !$article -> _values['enabled'] || $article -> _values['archive'] )
|
||||
return false;
|
||||
|
||||
$tpl = new \Savant3;
|
||||
$tpl -> _article = $article;
|
||||
return $tpl -> fetch( 'articles/article-draw' );
|
||||
}
|
||||
|
||||
public function drawEntryArticles( $articles )
|
||||
{
|
||||
$tpl = new \Savant3;
|
||||
$tpl -> _articles = $articles;
|
||||
return $tpl -> fetch( 'articles/articles-entry' );
|
||||
}
|
||||
|
||||
public function drawGallery( $id, $images )
|
||||
{
|
||||
$tpl = new \Savant3;
|
||||
$tpl -> _id = $id;
|
||||
$tpl -> _images = $images;
|
||||
return $tpl -> fetch( 'articles/article-gallery' );
|
||||
}
|
||||
|
||||
public static function drawFullArticles( $articles )
|
||||
{
|
||||
$tpl = new \Savant3;
|
||||
$tpl -> _articles = $articles;
|
||||
return $tpl -> fetch( 'articles/articles-full' );
|
||||
}
|
||||
}
|
||||
?>
|
||||
265
autoload/class.DataBase.php
Normal file
265
autoload/class.DataBase.php
Normal file
@@ -0,0 +1,265 @@
|
||||
<?php
|
||||
class DataBase
|
||||
{
|
||||
public function updateDataBase()
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> query( 'SHOW COLUMNS FROM pp_settings' );
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
if ( $row['Field'] == 'value' && $row['Type'] != 'text' )
|
||||
$query = $db -> query( 'ALTER TABLE pp_settings CHANGE value value TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL' );
|
||||
}
|
||||
$query -> closeCursor();
|
||||
|
||||
$query = $db -> query( 'SELECT 1 FROM pp_langs_text WHERE text = "T_PROSZE_WYBRAC_KOSZT_TRANSPORTU"' );
|
||||
if ( !$query -> rowCount() )
|
||||
$db -> query( 'INSERT INTO pp_langs_text ( text, pl ) VALUES ( "T_PROSZE_WYBRAC_KOSZT_TRANSPORTU", "Proszę wybrać koszt transportu." )' );
|
||||
|
||||
$query = $db -> query( 'SELECT 1 FROM pp_langs_text WHERE text = "T_KOSZT_TRANSPORTU"' );
|
||||
if ( !$query -> rowCount() )
|
||||
$db -> query( 'INSERT INTO pp_langs_text ( text, pl ) VALUES ( "T_KOSZT_TRANSPORTU", "Koszt transportu" )' );
|
||||
|
||||
$query = $db -> query( 'CREATE TABLE IF NOT EXISTS `pp_transport` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(255) COLLATE utf8_polish_ci NOT NULL,
|
||||
`cost` decimal(12,2) NOT NULL,
|
||||
`enabled` int(11) NOT NULL DEFAULT \'0\',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci AUTO_INCREMENT=1;' );
|
||||
|
||||
self::add_column_if_not_exist( 'pp_products', 'round_unit', 'INTEGER DEFAULT 0' );
|
||||
self::add_column_if_not_exist( 'pp_orders', 'transport_name', 'varchar(255) DEFAULT NULL' );
|
||||
self::add_column_if_not_exist( 'pp_orders', 'transport_cost', 'decimal(12,2) DEFAULT NULL' );
|
||||
}
|
||||
|
||||
public function add_column_if_not_exist( $table, $column, $column_attr = "VARCHAR( 255 ) NULL" )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> query( 'SHOW COLUMNS FROM ' . $table . ' LIKE "' . $column . '"' );
|
||||
if ( !$query -> rowCount() )
|
||||
$db -> query( 'ALTER TABLE ' . $table . ' ADD ' . $column . ' ' . $column_attr );
|
||||
$query -> closeCursor();
|
||||
}
|
||||
|
||||
public static function SaveData( $db_edit_table, $db_edit_key, $db_edit_val, $db_edit_pols, $db_edit_pass, $db_edit_pols_t )
|
||||
{
|
||||
global $lang, $db;
|
||||
|
||||
$sql = '';
|
||||
|
||||
if ( is_array( $db_edit_pols ) ) foreach ( $db_edit_pols as $val )
|
||||
{
|
||||
if ( $sql && $val != 'image' )
|
||||
$sql .= ',';
|
||||
if ( $val != 'image' )
|
||||
$sql .= $val . "='" . addslashes( \System::saveString( \System::formGet( $val ) ) ) . "'";
|
||||
}
|
||||
|
||||
if ( $db_edit_pass )
|
||||
{
|
||||
$name = $db_edit_pass['nazwa1'];
|
||||
$pass1 = \System::saveString( \System::formGet( $name ) );
|
||||
$pass2 = \System::saveString( \System::formGet( $name . '_repeat' ) );
|
||||
if ( $pass1 != $pass2 )
|
||||
\System::setAlert( $lang -> getTrans( 'T_HASLA_ROZNE' ) );
|
||||
else
|
||||
{
|
||||
if ( strlen($pass1) >= 5 )
|
||||
{
|
||||
if ( $sql )
|
||||
$sql .= ',';
|
||||
$sql .= $name . "='" . md5($pass1) . "'";
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( strlen( $pass1 ) < 5 )
|
||||
\System::setAlert( $lang -> getTrans( 'T_HASLA_ZA_KROTKIE' ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( $db_edit_table && $db_edit_key && $db_edit_val && $db_edit_pols )
|
||||
{
|
||||
$db_edit_table = \System::saveString( $db_edit_table );
|
||||
$db_edit_key = \System::saveString( $db_edit_key );
|
||||
$db_edit_val = \System::saveString( $db_edit_val );
|
||||
|
||||
$query = $db -> query( "UPDATE " . $db_edit_table . " SET " . $sql . " WHERE " . $db_edit_key . "='" . $db_edit_val . "'" );
|
||||
|
||||
for ( $i = 0; $i < count( $db_edit_pols_t ); $i++ )
|
||||
{
|
||||
if ( $db_edit_pols_t[$i] == 'file' && is_array( $_FILES[$db_edit_pols[$i]] ) )
|
||||
{
|
||||
$file = $_FILES[$db_edit_pols[$i]];
|
||||
if ( $file['name'] )
|
||||
$name = explode( '.' , $file['name'] );
|
||||
if ( isset( $name ) && is_array( $name ) )
|
||||
$patch = '../' . \System::formGet( 'image_folder' ) . md5( time() ). '.' . strtolower( $name[count( $name ) - 1] );
|
||||
|
||||
if ( $file['type'] == 'image/pjpeg' || $file['type'] == 'image/jpg' || $file['type'] == 'image/jpeg' || $file['type'] == 'image/gif' || $file['type'] == 'image/png' )
|
||||
{
|
||||
if ( $file['size'] < 5000000 )
|
||||
{
|
||||
$x = getimagesize( $file['tmp_name'] );
|
||||
if ( is_array( $x ) or $x[0] < 2)
|
||||
{
|
||||
$query = $db -> prepare( "SELECT " . $db_edit_pols[$i] . " FROM " . $db_edit_table . " WHERE " . $db_edit_key . "='" . $db_edit_val . "'" );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
if ( file_exists( '../' . $row[0] ) )
|
||||
unlink( '../' . $row[0] );
|
||||
}
|
||||
$query -> closeCursor();
|
||||
|
||||
if ( file_exists( $patch ) )
|
||||
unlink( $patch );
|
||||
|
||||
rename( $file['tmp_name'] , $patch );
|
||||
chmod( $patch , 0755 );
|
||||
$patch = str_replace( '../' , '' , $patch );
|
||||
$query = $db -> query( "UPDATE " . $db_edit_table . " SET " . $db_edit_pols[$i] ."='" . $patch . "' WHERE " . $db_edit_key . "='" . $db_edit_val . "'" );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
\System::setAlert( $lang -> getTrans( 'T_ZAKTUALIZOWANO_ELEMENT' ) );
|
||||
}
|
||||
$saveFlag = true;
|
||||
\System::deleteCacheAdmin();
|
||||
\System::deleteCache();
|
||||
}
|
||||
|
||||
public static function addData( $db_edit_table , $db_edit_pols , $db_edit_pols_hidden , $db_edit_pols_t , $time , $db_edit_pass = '' )
|
||||
{
|
||||
global $lang , $db;
|
||||
|
||||
$flag = true;
|
||||
$idk = '';
|
||||
$key = '';
|
||||
$val = '';
|
||||
$value = '';
|
||||
|
||||
if ( $time == \System::getSessionVar( 'dbedit_add_time' ) ) return false;
|
||||
|
||||
if ( is_array( $db_edit_pols ) ) foreach ( $db_edit_pols as $val )
|
||||
{
|
||||
if ( !$idk )
|
||||
$idk = $val;
|
||||
if ( $key )
|
||||
$key .= ',';
|
||||
if ( $value )
|
||||
$value .= ',';
|
||||
$key .= $val;
|
||||
$value .= "'" . \System::saveString( \System::formGet( $val ) ) . "'";
|
||||
}
|
||||
|
||||
if ( is_array( $db_edit_pols_hidden ) ) foreach ( $db_edit_pols_hidden as $val )
|
||||
{
|
||||
if ( $key )
|
||||
$key .= ',';
|
||||
if ( $value )
|
||||
$value .= ',';
|
||||
$key .= $val;
|
||||
$value .= "'" . \System::saveString( \System::formGet( $val ) ) . "'";
|
||||
}
|
||||
|
||||
if ( $db_edit_pass )
|
||||
{
|
||||
$name = $db_edit_pass['nazwa1'];
|
||||
$pass1 = \System::saveString( \System::formGet( $name ) );
|
||||
$pass2 = \System::saveString( \System::formGet( $name . '_repeat' ) );
|
||||
if ( $pass1 != $pass2 )
|
||||
{
|
||||
\System::setAlert( $lang -> getTrans( 'T_HASLA_ROZNE' ) );
|
||||
$flag = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( strlen($pass1) >= 5 )
|
||||
{
|
||||
if ( $key )
|
||||
$key .= ',';
|
||||
$key .= $name;
|
||||
if ( $value )
|
||||
$value .= ',';
|
||||
$value .= "'" . md5( $pass1 ) . "'";
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( $pass1 )
|
||||
{
|
||||
$flag = false;
|
||||
\System::setAlert( $lang -> getTrans( 'T_HASLA_ZA_KROTKIE' ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( $db_edit_table && $db_edit_pols && $flag )
|
||||
{
|
||||
$check = true;
|
||||
$db_edit_table = \System::saveString( $db_edit_table );
|
||||
try
|
||||
{
|
||||
$query = $db -> prepare( "INSERT INTO " . $db_edit_table . " (" . $key . ") VALUES (" . $value . ")");
|
||||
$query -> execute();
|
||||
}
|
||||
catch(PDOException $e)
|
||||
{
|
||||
$check = false;
|
||||
}
|
||||
|
||||
$id = $db -> lastInsertId();
|
||||
$query -> closeCursor();
|
||||
|
||||
for ( $i = 0; $i < count( $db_edit_pols_t ); $i++ )
|
||||
{
|
||||
if ( $db_edit_pols_t[$i] == 'file' && is_array($_FILES[$db_edit_pols[$i]]) )
|
||||
{
|
||||
$file = $_FILES[$db_edit_pols[$i]];
|
||||
$name = explode( '.' , $file['name'] );
|
||||
$patch = '../' . \System::formGet( 'image_folder' ) . md5( time() ). '.' . strtolower( $name[count( $name ) - 1] );
|
||||
|
||||
if ( $file['type'] == 'image/pjpeg' || $file['type'] == 'image/jpg' || $file['type'] == 'image/jpeg' || $file['type'] == 'image/gif' || $file['type'] == 'image/png' )
|
||||
{
|
||||
if ( $file['size'] < 5000000 )
|
||||
{
|
||||
if ( !is_dir( '../' . \System::formGet( 'image_folder' ) ) ) mkdir( '../' . \System::formGet( 'image_folder' ), 0775, true);
|
||||
$x = getimagesize( $file['tmp_name'] );
|
||||
if ( is_array( $x ) or $x[0] < 2)
|
||||
{
|
||||
if ( file_exists( $patch ) )
|
||||
unlink( $patch );
|
||||
|
||||
@rename( $file['tmp_name'] , $patch );
|
||||
chmod( $patch , 0755 );
|
||||
$patch = str_replace( '../' , '' , $patch );
|
||||
|
||||
$query = $db -> prepare( "UPDATE " . $db_edit_table . " SET " . $db_edit_pols[$i] . "='" . $patch . "' WHERE id='" . $id . "'" );
|
||||
$query -> execute();
|
||||
$query -> closeCursor();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( $check )
|
||||
\System::setAlert( 'Nowy element został dodany.' );
|
||||
else
|
||||
\System::setAlert( 'Podane dane są nieprawidłowe.' );
|
||||
$addFlag = true;
|
||||
}
|
||||
else
|
||||
\System::setAlert( 'Podane dane są nieprawidłowe.' );
|
||||
|
||||
\System::setSessionVar( 'dbedit_add_time' , $time );
|
||||
\System::deleteCacheAdmin();
|
||||
\System::deleteCache();
|
||||
}
|
||||
}
|
||||
?>
|
||||
526
autoload/class.DataBrowse.php
Normal file
526
autoload/class.DataBrowse.php
Normal file
@@ -0,0 +1,526 @@
|
||||
<?php
|
||||
class DataBrowse {
|
||||
private $_table;
|
||||
private $_filtr;
|
||||
private $_field_id;
|
||||
private $_field_name;
|
||||
private $_field_link;
|
||||
private $_field_style;
|
||||
private $_quantity;
|
||||
private $_select;
|
||||
private $_field_simple_id;
|
||||
private $_param;
|
||||
private $_field_action;
|
||||
private $_field_tran;
|
||||
private $_row_number;
|
||||
private $_count;
|
||||
private $_page_number;
|
||||
private $_sort;
|
||||
private $_filtr_id;
|
||||
private $_filtr_name;
|
||||
private $_filtr_field_tran;
|
||||
private $_filtr_quantity;
|
||||
private $_db_filtr;
|
||||
private $_db_filtr_value;
|
||||
private $_is_lp;
|
||||
private $_lp;
|
||||
private $_group_by;
|
||||
private $_filtr_type;
|
||||
private $_debug;
|
||||
private $_limit = 25;
|
||||
private $_filed_sort;
|
||||
private $_sort_name;
|
||||
private $_sort_way;
|
||||
private $_paging_adress = 'index.php';
|
||||
private $_cut;
|
||||
private $_checkbox = false;
|
||||
private $_menu = false;
|
||||
|
||||
function DataBrowse( $table , $filtr = '' , $debug = false )
|
||||
{
|
||||
$this -> _table = $table;
|
||||
$this -> _filtr = $filtr;
|
||||
$this -> _quantity = 0;
|
||||
$this -> _filtr_quantity = 0;
|
||||
$this -> _debug = $debug;
|
||||
}
|
||||
|
||||
public function addMenu( $html )
|
||||
{
|
||||
$this -> _menu = $html;
|
||||
}
|
||||
|
||||
public function addCheckbox()
|
||||
{
|
||||
$this -> _checkbox = true;
|
||||
}
|
||||
|
||||
function addGroupBy( $value )
|
||||
{
|
||||
$this -> _group_by = $value;
|
||||
}
|
||||
|
||||
function addLp()
|
||||
{
|
||||
$this -> _is_lp = true;
|
||||
$this -> _lp = true;
|
||||
}
|
||||
|
||||
function setLimit( $val )
|
||||
{
|
||||
$this -> _limit = $val;
|
||||
}
|
||||
|
||||
function addFiltr( $id , $nazwa , $tab = '' , $sql = '' )
|
||||
{
|
||||
global $db;
|
||||
if ( $nazwa )
|
||||
{
|
||||
$this -> _filtr_id[ $this -> _filtr_quantity ] = $id;
|
||||
$this -> _filtr_name[ $this -> _filtr_quantity ] = $nazwa;
|
||||
if ( $sql )
|
||||
{
|
||||
$query = $db -> prepare( $sql );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
$tab[ $row[0] ] = $row[1];
|
||||
$query -> closeCursor();
|
||||
}
|
||||
if ( is_array($tab) )
|
||||
$this -> _filtr_field_tran[$this -> _filtr_quantity] = $tab;
|
||||
else
|
||||
{
|
||||
if ( !$tab )
|
||||
$tab = 'text';
|
||||
$this -> _filtr_type[ $this -> _filtr_quantity ] = $tab;
|
||||
}
|
||||
$this -> _filtr_quantity++;
|
||||
}
|
||||
}
|
||||
|
||||
function addPosition( $id, $nazwa, $link = '', $tab = '', $style = '', $sort = false, $cut = true, $js = '' )
|
||||
{
|
||||
global $db;
|
||||
if ( $nazwa )
|
||||
{
|
||||
$this -> _field_id[ $this -> _quantity ] = $id;
|
||||
$this -> _field_name[ $this -> _quantity ] = $nazwa;
|
||||
$this -> _field_link[ $id ] = $link;
|
||||
$this -> _field_style[ $id ] = $style;
|
||||
$this -> _filed_sort[ $this -> _quantity ] = $sort;
|
||||
$this -> _field_cut[ $id ] = $cut;
|
||||
$this -> _field_js[ $id ] = $js;
|
||||
if ( is_array( $tab ) )
|
||||
$this -> _field_tran[$id] = $tab;
|
||||
else
|
||||
{
|
||||
if ( $tab )
|
||||
{
|
||||
$query = $db -> prepare($tab);
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $res = $query -> fetch() )
|
||||
$tabs[$res[0]] = $res[1];
|
||||
$query -> closeCursor();
|
||||
$tabs[0] = '';
|
||||
$this -> _field_tran[$id] = $tabs;
|
||||
}
|
||||
}
|
||||
$this -> _quantity ++;
|
||||
}
|
||||
}
|
||||
|
||||
function addPositionSimple( $id , $nazwa , $link = '' , $akcja = '' , $style = '' )
|
||||
{
|
||||
$this -> _field_simple_id[$this -> _quantity] = $id;
|
||||
$this -> _field_name[$this -> _quantity] = $nazwa;
|
||||
$this -> _field_link[$id] = $link;
|
||||
$this -> _field_action[$id] = $akcja;
|
||||
$this -> _field_style[$id] = $style;
|
||||
$this -> _filed_sort[ $this -> _quantity ] = false;
|
||||
$this -> _quantity++;
|
||||
}
|
||||
|
||||
function setParam( $param )
|
||||
{
|
||||
$this -> _param = $param;
|
||||
}
|
||||
|
||||
function addSort( $sort )
|
||||
{
|
||||
$this -> _sort = $sort;
|
||||
}
|
||||
|
||||
function draw()
|
||||
{
|
||||
global $db , $bs;
|
||||
|
||||
$out = '';
|
||||
$filtr_ttext = '';
|
||||
$filtr_combo = '';
|
||||
$table_values = '';
|
||||
$filtr_text = '';
|
||||
|
||||
if ( \System::formGet( 'bs' ) ) {
|
||||
\System::setSessionVar( $this -> _table . '_bs' , \System::formGet('bs' ) );
|
||||
}
|
||||
$bs = \System::getSessionVar( $this -> _table . '_bs' );
|
||||
|
||||
$page_type = \System::getSessionVar( 'page_type' );
|
||||
|
||||
if ( \System::formGet( 's' ) )
|
||||
{
|
||||
if ( \System::getSessionVar( $this -> _table . '_sort' . \System::formGet( 's' ) ) == 'DESC' )
|
||||
\System::setSessionVar( $this -> _table . '_sort' . \System::formGet( 's' ) , 'ASC' );
|
||||
else
|
||||
\System::setSessionVar( $this -> _table . '_sort' . \System::formGet( 's' ) , 'DESC' );
|
||||
\System::setSessionVar( $this -> _table . '_sort_by', \System::formGet( 's' ) );
|
||||
}
|
||||
|
||||
$sort = \System::getSessionVar( $this -> _table . '_sort_by' );
|
||||
|
||||
if ( $sort )
|
||||
{
|
||||
$this -> _sort = $sort . ' ' . \System::getSessionVar( $this -> _table . '_sort' . $sort );
|
||||
$this -> _sort_name = $sort;
|
||||
$this -> _sort_way = \System::getSessionVar( $this -> _table . '_sort' . $sort );
|
||||
}
|
||||
|
||||
if ( \System::formGetInt( 'r' ) )
|
||||
\System::setSessionVar( $this -> _table . '_limit' , \System::formGetInt( 'r' ) );
|
||||
|
||||
$limit = \System::getSessionVar( $this -> _table . '_limit' );
|
||||
if ( !$limit )
|
||||
$limit = $this -> _limit;
|
||||
switch ( $limit )
|
||||
{
|
||||
case 5:
|
||||
$this -> _limit = 5;
|
||||
break;
|
||||
case 10:
|
||||
$this -> _limit = 10;
|
||||
break;
|
||||
case 25:
|
||||
$this -> _limit = 25;
|
||||
break;
|
||||
case 50:
|
||||
$this -> _limit = 50;
|
||||
break;
|
||||
case 100:
|
||||
$this -> _limit = 100;
|
||||
break;
|
||||
default:
|
||||
$this -> _limit = 25;
|
||||
break;
|
||||
}
|
||||
|
||||
if ( \System::formGet( 'set_db_filtr' ) == 'yes' )
|
||||
{
|
||||
if ( is_array( $_POST ) ) foreach ( $_POST as $key => $val )
|
||||
{
|
||||
if ( $key != 'set_db_filtr' && $val != '' && $key != 'rows' )
|
||||
{
|
||||
$this -> _db_filtr_value[$key] = $val;
|
||||
$pos_title = array_search( $this -> _db_filtr_value[ $key ] , $this -> _db_filtr_value );
|
||||
$position = array_search( $pos_title , $this -> _filtr_id );
|
||||
|
||||
if ( $this -> _db_filtr && strpos( $key , '{trans}_trans' ) === false )
|
||||
$this -> _db_filtr .= ' AND ';
|
||||
|
||||
if ( isset( $this -> _filtr_type[ $position ] ) && $this -> _filtr_type[ $position ] == 'text' )
|
||||
$this -> _db_filtr .= " $key LIKE '%$val%' ";
|
||||
else
|
||||
{
|
||||
if ( strpos( $key , '{trans}_trans' ) === false )
|
||||
{
|
||||
if ( strpos( $key , '{trans}' ) && is_array( \System::formGet( $key . '_trans' ) ) )
|
||||
{
|
||||
$count = 0;
|
||||
$this -> _db_filtr .= ' ( ';
|
||||
foreach ( \System::formGet( $key . '_trans' ) as $value_tmp )
|
||||
{
|
||||
$value_tmp = explode( '[]' , $value_tmp );
|
||||
if ( strpos( strtolower( $value_tmp[1] ) , strtolower( $val ) ) !== false )
|
||||
{
|
||||
if ( $this -> _db_filtr_tmp )
|
||||
$this -> _db_filtr_tmp .= ' OR ';
|
||||
$this -> _db_filtr_tmp .= str_replace( '{trans}' , '' , $key ) . " = '" . $value_tmp[0] . "'";
|
||||
}
|
||||
else
|
||||
$count++;
|
||||
}
|
||||
|
||||
if ( count( \System::formGet( $key . '_trans' ) ) == $count )
|
||||
$this -> _db_filtr_tmp .= str_replace( '{trans}' , '' , $key ) . " = ''";
|
||||
|
||||
$this -> _db_filtr .= $this -> _db_filtr_tmp . ' ) ';
|
||||
}
|
||||
else
|
||||
$this -> _db_filtr .= " $key = '$val'";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
\System::setSessionVar( 'db_filtr_' . $page_type , $this -> _db_filtr );
|
||||
\System::setSessionVar( 'db_filtr_value_' . $page_type , $this -> _db_filtr_value );
|
||||
}
|
||||
|
||||
if ( \System::formGet( 'set_db_filtr' ) == 'no' )
|
||||
{
|
||||
\System::deleteSessionVar( 'db_filtr_' . $page_type );
|
||||
\System::deleteSessionVar( 'db_filtr_value_' . $page_type );
|
||||
}
|
||||
$this -> _db_filtr = \System::getSessionVar( 'db_filtr_' . $page_type );
|
||||
$this -> _db_filtr_value = \System::getSessionVar( 'db_filtr_value_' . $page_type );
|
||||
|
||||
$tpl = new \Savant3;
|
||||
|
||||
if ( is_array( $this -> _filtr_id ) )
|
||||
{
|
||||
$tpl -> _filtr = true;
|
||||
for ( $x = 0; $x < $this -> _filtr_quantity; $x++ )
|
||||
{
|
||||
if ( isset( $this -> _filtr_field_tran[$x] ) )
|
||||
{
|
||||
if ( strpos( $this -> _filtr_id[$x] , '{trans}' ) !== false )
|
||||
{
|
||||
$filtr_tt['name'] = $this -> _filtr_name[ $x ];
|
||||
$filtr_tt['seo_name'] = $this -> _filtr_id[ $x ];
|
||||
if ( isset( $this -> _db_filtr_value[ $this -> _filtr_id[ $x ] ] ))
|
||||
$filtr_tt['value'] = $this -> _db_filtr_value[ $this -> _filtr_id[ $x ] ];
|
||||
else
|
||||
$filtr_tt['value'] = '';
|
||||
if ( is_array($this -> _filtr_field_tran[$x]) ) foreach ( $this -> _filtr_field_tran[$x] as $key => $val )
|
||||
$filtr_tt['select'][$key] = $val;
|
||||
|
||||
$filtr_ttext[] = $filtr_tt;
|
||||
}
|
||||
else
|
||||
{
|
||||
$filtr_c = '';
|
||||
$filtr_c['name'] = $this -> _filtr_name[$x];
|
||||
$filtr_c['seo_name'] = $this -> _filtr_id[$x];
|
||||
|
||||
if ( is_array( $this -> _filtr_field_tran[$x] ) ) foreach ( $this -> _filtr_field_tran[$x] as $key => $val )
|
||||
$filtr_c['value'][$key] = $val;
|
||||
|
||||
if ( isset( $this -> _db_filtr_value[$this -> _filtr_id[$x]] ) )
|
||||
$filtr_c['val'] = $this -> _db_filtr_value[$this -> _filtr_id[$x]];
|
||||
|
||||
$filtr_combo[] = $filtr_c;
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset( $this -> _filtr_type[$x] ) && $this -> _filtr_type[$x] == 'text' )
|
||||
{
|
||||
$filtr_t['name'] = $this -> _filtr_name[$x];
|
||||
$filtr_t['seo_name'] = $this -> _filtr_id[$x];
|
||||
if ( isset( $this -> _db_filtr_value[$this -> _filtr_id[$x]] ) )
|
||||
$filtr_t['value'] = $this -> _db_filtr_value[$this -> _filtr_id[$x]];
|
||||
else
|
||||
$filtr_t['value'] = '';
|
||||
$filtr_text[] = $filtr_t;
|
||||
}
|
||||
|
||||
if ( isset( $this -> _filtr_type[$x] ) && $this -> _filtr_type[$x] == 'text-trans' )
|
||||
{
|
||||
$filtr_tt['name'] = $this -> _filtr_name[ $x ];
|
||||
$filtr_tt['seo_name'] = $this -> _filtr_id[ $x ];
|
||||
$filtr_tt['value'] = $this -> _db_filtr_value[ $this -> _filtr_id[ $x ] ];
|
||||
if ( is_array($this -> _filtr_field_tran[$x]) ) foreach ( $this -> _filtr_field_tran[$x] as $key => $val )
|
||||
$filtr_tt['select'][$key] = $val;
|
||||
$filtr_ttext[] = $filtr_tt;
|
||||
}
|
||||
}
|
||||
$tpl -> _filtr_ttext = $filtr_ttext;
|
||||
$tpl -> _filtr_combo = $filtr_combo;
|
||||
$tpl -> _filtr_text = $filtr_text;
|
||||
}
|
||||
|
||||
if ( is_array($this -> _field_id) ) foreach ( $this -> _field_id as $p )
|
||||
{
|
||||
if ( !$this -> _select )
|
||||
{
|
||||
$this -> _select = $p;
|
||||
if ( !$this -> _param )
|
||||
$this -> _param = $p;
|
||||
}
|
||||
else
|
||||
$this -> _select .= ", $p";
|
||||
}
|
||||
if ( is_array( $this -> _field_id ) && !in_array( $this -> _param,$this -> _field_id ) )
|
||||
$this -> _select .= ", " . $this -> _param;
|
||||
|
||||
$sql_t = "SELECT count(1) FROM " . $this -> _table;
|
||||
|
||||
$sql = "SELECT " . $this -> _select . " FROM " . $this -> _table;
|
||||
if ( $this -> _filtr )
|
||||
{
|
||||
$sql .= " WHERE " . $this -> _filtr;
|
||||
$sql_t .= " WHERE " . $this -> _filtr;
|
||||
}
|
||||
if ( $this -> _filtr && $this -> _db_filtr )
|
||||
{
|
||||
$sql .= " AND " . $this -> _db_filtr;
|
||||
$sql_t .= " AND " . $this -> _db_filtr;
|
||||
}
|
||||
else if ( !$this -> _filtr && $this -> _db_filtr )
|
||||
{
|
||||
$sql .= " WHERE " . $this -> _db_filtr;
|
||||
$sql_t .= " WHERE " . $this -> _db_filtr;
|
||||
}
|
||||
if ( $this -> _group_by )
|
||||
{
|
||||
$sql .= ' GROUP BY ' . $this -> _group_by;
|
||||
$sql_t .= ' GROUP BY ' . $this -> _group_by;
|
||||
}
|
||||
if ( $this -> _sort )
|
||||
{
|
||||
$sql .= " ORDER BY " . $this -> _sort;
|
||||
$sql_t .= " ORDER BY " . $this -> _sort;
|
||||
}
|
||||
|
||||
$query = $db -> prepare ($sql_t) ;
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
$count_rows = $row[0];
|
||||
|
||||
$ls = ceil( $count_rows / $this -> _limit );
|
||||
if ( (int)$bs > $ls )
|
||||
$bs = $ls;
|
||||
if ( (int)$bs < 1 )
|
||||
$bs = 1;
|
||||
$a = \System::getPagingVar( 'a' , $bs , $ls );
|
||||
$b = \System::getPagingVar( 'b' , $bs , $ls );
|
||||
|
||||
$tpl -> _a = $bs - $b;
|
||||
$tpl -> _b = $bs + $a;
|
||||
$tpl -> _ls = $ls;
|
||||
$tpl -> _link = $this -> _paging_adress;
|
||||
$tpl -> _bs = $bs;
|
||||
|
||||
if ( $this -> _limit )
|
||||
$sql .= " LIMIT " . ( $bs - 1 ) * $this -> _limit . "," . $this -> _limit;
|
||||
|
||||
$query = $db -> prepare( $sql );
|
||||
$query -> execute();
|
||||
|
||||
if ( $this -> _debug )
|
||||
print_r ($query -> errorInfo() );
|
||||
|
||||
$tpl -> _row_count = $query -> rowCount();
|
||||
|
||||
for ( $i = 0; $i < $this -> _quantity; $i++ )
|
||||
{
|
||||
if ( $this -> _is_lp )
|
||||
{
|
||||
$header[0]['value'] = 'Lp.';
|
||||
$this -> _is_lp = false;
|
||||
}
|
||||
$row['value'] = $this -> _field_name[$i];
|
||||
$row['sort'] = false;
|
||||
$row['way'] = false;
|
||||
|
||||
if ( $this -> _filed_sort[$i] )
|
||||
{
|
||||
$row['sort'] = $this -> _filed_sort[$i];
|
||||
if ( $this -> _sort_name == $this -> _filed_sort[$i] )
|
||||
$row['way'] = $this -> _sort_way;
|
||||
}
|
||||
$header[] = $row;
|
||||
}
|
||||
$tpl -> _table_headers = $header;
|
||||
|
||||
$i = $this -> _row_number * ( $bs - 1 ) + 1;
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
if ( $this -> _lp )
|
||||
{
|
||||
$values['lp']['style'] = 'text-align:center;';
|
||||
$values['lp']['value'] = ( $bs - 1 ) * $this -> _limit + $i . '.';
|
||||
}
|
||||
|
||||
if ( $this -> _checkbox )
|
||||
{
|
||||
$values['checkbox']['value'] = '<input type="checkbox" name="checkbox" value="' . $row[ $this -> _param ] . '">';
|
||||
}
|
||||
|
||||
if ( is_array($this -> _field_id) ) foreach ( $this -> _field_id as $key )
|
||||
{
|
||||
$values[$key]['value'] = '';
|
||||
|
||||
if ( $this -> _field_link[$key] )
|
||||
$values[$key]['value'] = '<a href="' . $this -> _field_link[$key] . '&id=' . $row[$this -> _param] . '">';
|
||||
|
||||
if ( isset( $this -> _field_tran[$key] ) && is_array($this -> _field_tran[$key]) )
|
||||
{
|
||||
if ( isset( $this -> _field_tran[$key][$row[$key]] ) )
|
||||
{
|
||||
if ( strlen( $this -> _field_tran[$key][$row[$key]] ) > 40 )
|
||||
$values[$key]['value'] .= mb_substr( $this -> _field_tran[$key][$row[$key]] , 0 , 40 , 'UTF-8' ) . '...';
|
||||
else
|
||||
{
|
||||
if ( $this->_field_tran[$key][$row[$key]] )
|
||||
$values[$key]['value'] .= $this -> _field_tran[$key][$row[$key]];
|
||||
else
|
||||
$values[$key]['value'] .= '';
|
||||
}
|
||||
}
|
||||
else
|
||||
$values[$key]['value'] .= '';
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( strlen( $row[$key] ) > 40 && $this -> _field_cut[$key] )
|
||||
$values[$key]['value'] .= mb_substr( strip_tags( $row[$key] ) , 0 , 40 , 'UTF-8' ) . '...';
|
||||
else
|
||||
$values[$key]['value'] .= $row[$key];
|
||||
}
|
||||
$values[$key]['style'] = $this -> _field_style[$key];
|
||||
$values[$key]['js'] = str_replace( '[param]', $row[ $this -> _param ], $this -> _field_js[ $key ] );
|
||||
|
||||
if ( $this -> _field_link[$key] || $this -> _field_action[$key] )
|
||||
$values[$key]['value'] .= '</a>';
|
||||
}
|
||||
|
||||
if ( is_array( $this -> _field_simple_id ) ) foreach ( $this -> _field_simple_id as $key )
|
||||
{
|
||||
$val_temp = '';
|
||||
|
||||
if ( $this -> _field_link[$key] )
|
||||
$val_temp .= '<a href="' . $this -> _field_link[$key] . '&id=' . $row[$this -> _param] . '">';
|
||||
|
||||
if ( $this -> _field_action[$key] )
|
||||
$val_temp .= '<a href="#" ' . str_replace('[param]',$row[$this -> _param],$this -> _field_action[$key]) . '>';
|
||||
|
||||
if ( $key == 'usuń' )
|
||||
$val_temp .= "<span class='icon delete' title='usuń'></span>";
|
||||
else if ( $key == 'edytuj' )
|
||||
$val_temp .= "<span class='icon edit' title='edytuj'></span>";
|
||||
else if ( $key == 'pokaż' )
|
||||
$val_temp .= "<span class='icon show' title='pokaż'></span>";
|
||||
else
|
||||
$val_temp .= $key;
|
||||
|
||||
if ( $this -> _field_link[$key] || $this -> _field_action[$key] )
|
||||
$val_temp .= '</a>';
|
||||
|
||||
$values[$key]['style'] = $this -> _field_style[$key];
|
||||
$values[$key]['value'] = $val_temp;
|
||||
}
|
||||
$table_values[] = $values;
|
||||
$i++;
|
||||
}
|
||||
|
||||
$tpl -> _menu = $this -> _menu;
|
||||
$tpl -> _table_values = $table_values;
|
||||
$tpl -> _limit = $this -> _limit;
|
||||
$tpl -> _start = $count_rows == 0 ? 0 : $this -> _limit * ( $bs - 1 ) + 1;
|
||||
$tpl -> _end = $this -> _limit * $bs > $count_rows ? $count_rows : $this -> _limit * $bs;
|
||||
$tpl -> _total = $count_rows;
|
||||
$tpl -> _checkbox = $this -> _checkbox;
|
||||
$out .= $tpl -> fetch( 'data/data-browse' );
|
||||
return $out;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
351
autoload/class.DataEdit.php
Normal file
351
autoload/class.DataEdit.php
Normal file
@@ -0,0 +1,351 @@
|
||||
<?php
|
||||
class DataEdit
|
||||
{
|
||||
private $_table;
|
||||
private $_key;
|
||||
private $_val;
|
||||
private $_field_id;
|
||||
private $_field_name;
|
||||
private $_field_type;
|
||||
private $_field_action;
|
||||
private $_quantity;
|
||||
private $_select;
|
||||
private $_password;
|
||||
private $_pass;
|
||||
private $_form_id;
|
||||
private $_quantity_hidden;
|
||||
private $_field_value_hidden;
|
||||
private $_field_key_hidden;
|
||||
private $_upload_quantity;
|
||||
private $_field_upload;
|
||||
private $_cancel_button;
|
||||
private $_param;
|
||||
private $_field_tab;
|
||||
|
||||
function DataEdit( $table , $key = '' , $val = '' , $adres = 'index.php' )
|
||||
{
|
||||
$this -> _table = $table;
|
||||
$this -> _adres = $adres;
|
||||
$this -> _quantity = 0;
|
||||
$this -> _quantity_hidden = 0;
|
||||
if ( $key && $val )
|
||||
{
|
||||
$this -> _key = $key;
|
||||
$this -> _val = $val;
|
||||
}
|
||||
}
|
||||
|
||||
function addPositionHidden( $key , $val )
|
||||
{
|
||||
$this -> _field_value_hidden[ $this -> _quantity_hidden ] = $val;
|
||||
$this -> _field_key_hidden[ $this -> _quantity_hidden ] = $key;
|
||||
$this -> _quantity_hidden ++;
|
||||
}
|
||||
|
||||
function addCancelButton( $nazwa , $key = '' , $val = '' )
|
||||
{
|
||||
$this -> _cancel_button['nazwa'] = $nazwa;
|
||||
$this -> _cancel_button['key'] = $key;
|
||||
$this -> _cancel_button['val'] = $val;
|
||||
}
|
||||
|
||||
function setFormId( $id )
|
||||
{
|
||||
$this -> _form_id = $id;
|
||||
}
|
||||
|
||||
function addPosition( $id, $nazwa, $typ, $action = '', $tab = '', $empty = false )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$this -> _field_id[$this -> _quantity] = $id;
|
||||
$this -> _field_name[$this -> _quantity] = $nazwa;
|
||||
$this -> _field_type[$this -> _quantity] = $typ;
|
||||
$this -> _field_action[$this -> _quantity] = $action;
|
||||
if ( is_array( $tab ) )
|
||||
$this -> _field_tab[$this -> _quantity] = $tab;
|
||||
else
|
||||
{
|
||||
if ( $tab )
|
||||
{
|
||||
$query = $db -> prepare($tab);
|
||||
$query -> execute();
|
||||
if ( $empty )
|
||||
$tabs[''] = '';
|
||||
if ( $query -> rowCount() ) while ( $res = $query -> fetch() )
|
||||
$tabs[$res[0]] = $res[1];
|
||||
$this -> _field_tab[$this -> _quantity] = $tabs;
|
||||
}
|
||||
}
|
||||
$this -> _quantity ++;
|
||||
}
|
||||
|
||||
function addHiddenParam( $id )
|
||||
{
|
||||
$this -> _param = $id;
|
||||
}
|
||||
|
||||
function setSubmitButton( $button )
|
||||
{
|
||||
$this -> _button_submit = $button;
|
||||
}
|
||||
|
||||
function addPositionPassword( $nazwa = '' , $action1 = '' , $action2 = '' )
|
||||
{
|
||||
$this -> _password = true;
|
||||
if ( isset( $nazwa ) )
|
||||
{
|
||||
$nazwa1 = 'password';
|
||||
$nazwa2 = 'password_repeat';
|
||||
}
|
||||
else
|
||||
$nazwa2 = $nazwa . '_repeat';
|
||||
$this -> _pass['nazwa1'] = $nazwa1;
|
||||
$this -> _pass['nazwa2'] = $nazwa2;
|
||||
$this -> _pass['action1'] = $action1;
|
||||
$this -> _pass['action2'] = $action2;
|
||||
}
|
||||
|
||||
function setUploadFolder( $id , $folder )
|
||||
{
|
||||
$this -> _upload_quantity ++;
|
||||
$this -> _field_upload[$this -> _upload_quantity]['id'] = $id;
|
||||
$this -> _field_upload[$this -> _upload_quantity]['folder'] = $folder;
|
||||
}
|
||||
|
||||
function draw()
|
||||
{
|
||||
global $db , $lang;
|
||||
|
||||
$hidden_tab = '';
|
||||
$hidden_param_tab = '';
|
||||
$out = '';
|
||||
|
||||
\System::setSessionVar( 'db_edit_table' , $this -> _table );
|
||||
\System::setSessionVar( 'db_edit_key' , $this -> _key );
|
||||
\System::setSessionVar( 'db_edit_val' , $this -> _val );
|
||||
\System::setSessionVar( 'db_edit_pols' , $this -> _field_id );
|
||||
\System::setSessionVar( 'db_edit_pass' , $this -> _pass );
|
||||
\System::setSessionVar( 'db_edit_pols_hidden', $this -> _field_key_hidden );
|
||||
\System::setSessionVar( 'db_edit_pols_type' , $this -> _field_type );
|
||||
|
||||
if ( !$this -> _form_id )
|
||||
$this -> _form_id = 'formularz';
|
||||
|
||||
$flaga = false;
|
||||
if ( is_array( $this -> _field_id ) ) foreach ( $this -> _field_id as $p )
|
||||
{
|
||||
if ( !$this -> _select )
|
||||
$this -> _select = $p;
|
||||
else
|
||||
$this -> _select .= ', ' . $p;
|
||||
}
|
||||
if ( $this -> _param )
|
||||
$this -> _select .= ", " . $this -> _param;
|
||||
|
||||
if ( $this -> _key )
|
||||
$flaga = true;
|
||||
|
||||
if ( $flaga )
|
||||
{
|
||||
$query = $db -> prepare( 'SELECT ' . $this -> _select . ' FROM ' . $this -> _table . ' WHERE ' . $this -> _key . '="' . $this -> _val . '"' );
|
||||
$query->execute();
|
||||
}
|
||||
|
||||
$tpl = new \Savant3;
|
||||
|
||||
$tpl -> _form_adress = $this -> _adres;
|
||||
$tpl -> _form_id = $this -> _form_id;
|
||||
|
||||
if ( is_array( $this -> _field_key_hidden ) )
|
||||
{
|
||||
for ( $j = 0; $j < $this -> _quantity_hidden; $j++ )
|
||||
{
|
||||
$hidden['name'] = $this -> _field_key_hidden[$j];
|
||||
$hidden['value'] = $this -> _field_value_hidden[$j];
|
||||
$hidden_tab[] = $hidden;
|
||||
}
|
||||
}
|
||||
$tpl -> _hidden_tab = $hidden_tab;
|
||||
$tpl -> _form_key = $this -> _key;
|
||||
$tpl -> _form_val = $this -> _val;
|
||||
|
||||
if ( $flaga )
|
||||
{
|
||||
if ( $query -> rowCount() ) while ( $res = $query -> fetch() )
|
||||
{
|
||||
if ( $this -> _param )
|
||||
{
|
||||
$hidden_param['name'] = $this -> _param;
|
||||
$hidden_param['value'] = $res[$this -> _param];
|
||||
$hidden_param_tab[] = $hidden_param;
|
||||
}
|
||||
}
|
||||
}
|
||||
$tpl -> _hidden_param_tab = $hidden_param_tab;
|
||||
|
||||
for ( $i = 0; $i < $this -> _quantity; $i++ )
|
||||
{
|
||||
$table_edit['tr_id'] = $this -> _field_id[$i];
|
||||
$table_edit['name'] = $this -> _field_name[$i];
|
||||
|
||||
if ( $this -> _field_type[$i] == "label" )
|
||||
{
|
||||
|
||||
$table_edit['type'] = 'label';
|
||||
$table_edit['input_id'] = $this -> _field_id[$i];
|
||||
$table_edit['input_name'] = $this -> _field_id[$i];
|
||||
$table_edit['input_action'] = $this -> _field_action[$i];
|
||||
|
||||
if ( $flaga )
|
||||
{
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $res = $query -> fetch() )
|
||||
$table_edit['input_value'] = $res[$i];
|
||||
}
|
||||
else
|
||||
$table_edit['input_value'] = '';
|
||||
|
||||
if ( isset( $this -> _filed_tab[$i] ) && is_array( $this -> _field_tab[$i] ) ) foreach ( $this -> _field_tab[$i] as $key => $val )
|
||||
{
|
||||
if ( $flaga )
|
||||
{
|
||||
if ( $key == $res[$i] )
|
||||
$table_edit['text'] = $val;
|
||||
}
|
||||
}
|
||||
else
|
||||
$table_edit['text'] = $res[$i];
|
||||
}
|
||||
else if ( $this -> _field_type[$i] == 'text' )
|
||||
{
|
||||
$table_edit['type'] = 'text';
|
||||
$table_edit['input_id'] = $this -> _field_id[$i];
|
||||
$table_edit['input_name'] = $this -> _field_id[$i];
|
||||
$table_edit['input_action'] = $this -> _field_action[$i];
|
||||
if ( $flaga )
|
||||
{
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $res = $query -> fetch() )
|
||||
$table_edit['input_value'] = $res[$i];
|
||||
}
|
||||
else
|
||||
$table_edit['input_value'] = '';
|
||||
|
||||
}
|
||||
else if ( $this -> _field_type[$i] == 'radio' )
|
||||
{
|
||||
$table_edit['type'] = 'radio';
|
||||
$table_edit['input_id'] = $this -> _field_id[$i];
|
||||
$table_edit['input_name'] = $this -> _field_id[$i];
|
||||
$table_edit['input_action'] = $this -> _field_action[$i];
|
||||
$value = '';
|
||||
if ( is_array( $this -> _field_tab[$i] ) ) foreach ( $this -> _field_tab[$i] as $key => $val )
|
||||
{
|
||||
$value[$key] = $lang -> getTrans( $val );
|
||||
$table_edit['input_value'] = $value;
|
||||
if ( $flaga )
|
||||
{
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $res = $query -> fetch() )
|
||||
{
|
||||
if ( $key == $res[$i] )
|
||||
$table_edit['var'] = $res[$i];
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
$table_edit['input_value'] = '';
|
||||
}
|
||||
else if ( $this -> _field_type[$i] == 'textarea' )
|
||||
{
|
||||
|
||||
$table_edit['type'] = 'textarea';
|
||||
$table_edit['input_id'] = $this -> _field_id[$i];
|
||||
$table_edit['input_name'] = $this -> _field_id[$i];
|
||||
if ( $flaga )
|
||||
{
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $res = $query -> fetch() )
|
||||
$table_edit['input_value'] = $res[$i];
|
||||
}
|
||||
else
|
||||
$table_edit['input_value'] = '';
|
||||
|
||||
}
|
||||
else if ( $this -> _field_type[$i] == 'file' )
|
||||
{
|
||||
|
||||
$table_edit['type'] = 'file';
|
||||
$table_edit['input_id'] = $this -> _field_id[$i];
|
||||
$table_edit['input_name'] = 'image';
|
||||
if ( $flaga )
|
||||
{
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $res = $query -> fetch() )
|
||||
$table_edit['input_value'] = $res[$i];
|
||||
}
|
||||
else
|
||||
$table_edit['input_value'] = '';
|
||||
|
||||
}
|
||||
else if ( $this -> _field_type[$i] == 'combo' )
|
||||
{
|
||||
$table_edit['type'] = 'combo';
|
||||
$table_edit['input_id'] = $this -> _field_id[$i];
|
||||
$table_edit['input_name'] = $this -> _field_id[$i];
|
||||
$table_edit['input_action'] = $this -> _field_action[$i];
|
||||
|
||||
$value = '';
|
||||
if ( is_array( $this -> _field_tab[$i] ) ) foreach ( $this -> _field_tab[$i] as $key => $val )
|
||||
{
|
||||
$value[$key] = $lang -> getTrans( $val );
|
||||
$table_edit['input_value'] = $value;
|
||||
if ( $flaga )
|
||||
{
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $res = $query -> fetch() )
|
||||
{
|
||||
if ( $key == $res[$i] )
|
||||
$table_edit['var'] = $res[$i];
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
$table_edit['input_value'] = '';
|
||||
}
|
||||
$table_edit_tab[] = $table_edit;
|
||||
}
|
||||
if ( $this -> _password )
|
||||
{
|
||||
$tpl -> _password = $this -> _password;
|
||||
$tpl -> _pass_name1 = $this -> _pass['nazwa1'];
|
||||
$tpl -> _pass_action = $this -> _pass['action1'];
|
||||
$tpl -> _pass_name2 = $this -> _pass['nazwa2'];
|
||||
$tpl -> _pass_action2 = $this -> _pass['action2'];
|
||||
}
|
||||
if ( is_array( $this -> _field_upload ) )
|
||||
{
|
||||
$tpl -> _file_upload = true;
|
||||
for ( $j=1; $j<=$this -> _upload_quantity; $j++ )
|
||||
{
|
||||
$upload['name'] = $this -> _field_upload[$j]['id'] . '_folder';
|
||||
$upload['value'] = $this -> _field_upload[$j]['folder'];
|
||||
$upload_tab[] = $upload;
|
||||
}
|
||||
$tpl -> _upload_tab = $upload_tab;
|
||||
}
|
||||
if ( $this -> _cancel_button )
|
||||
{
|
||||
$tpl -> _cancel_button = true;
|
||||
$tpl -> _cancel_adress = $this -> _adres;
|
||||
$tpl -> _cancel_name = $this -> _cancel_button['nazwa'];
|
||||
$tpl -> _cancel_key = $this -> _cancel_button['key'];
|
||||
$tpl -> _cancel_val = $this -> _cancel_button['val'];
|
||||
}
|
||||
$tpl -> _table_edit_tab = $table_edit_tab;
|
||||
$out .= $tpl -> fetch( 'data/data-edit' );
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
?>
|
||||
48
autoload/class.FileCache.php
Normal file
48
autoload/class.FileCache.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
class FileCache
|
||||
{
|
||||
function store( $key , $data , $ttl )
|
||||
{
|
||||
$h = fopen( $this -> getFileName( $key ) , 'w' );
|
||||
if ( !$h )
|
||||
throw new Exception( 'Could not write to cache' );
|
||||
$data = base64_encode( serialize( array( time() + $ttl , $data ) ) );
|
||||
if ( fwrite( $h , $data ) === false )
|
||||
throw new Exception('Could not write to cache');
|
||||
fclose($h);
|
||||
}
|
||||
|
||||
private function getFileName( $key )
|
||||
{
|
||||
$md5 = md5( $key );
|
||||
$dir = 'temp/' . $md5[0] . '/';
|
||||
if ( !is_dir( $dir ) )
|
||||
mkdir( $dir , 0770 , true );
|
||||
return $dir . 's_cache' . $md5;
|
||||
}
|
||||
|
||||
function fetch( $key )
|
||||
{
|
||||
$filename = $this -> getFileName( $key );
|
||||
if ( !file_exists( $filename ) || !is_readable( $filename ) )
|
||||
return false;
|
||||
|
||||
$data = base64_decode( file_get_contents( $filename ) );
|
||||
|
||||
$data = @unserialize( $data );
|
||||
if ( !$data )
|
||||
{
|
||||
unlink($filename);
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( time() > $data[0] )
|
||||
{
|
||||
if ( file_exists( $filename ) )
|
||||
unlink( $filename );
|
||||
return false;
|
||||
}
|
||||
return $data[1];
|
||||
}
|
||||
}
|
||||
?>
|
||||
973
autoload/class.System.php
Normal file
973
autoload/class.System.php
Normal file
@@ -0,0 +1,973 @@
|
||||
<?php
|
||||
class System
|
||||
{
|
||||
function getImgFileTypes()
|
||||
{
|
||||
$mime_types = array(
|
||||
'image/png',
|
||||
'image/jpeg',
|
||||
'image/jpeg',
|
||||
'image/jpeg',
|
||||
'image/gif',
|
||||
'image/bmp',
|
||||
'image/vnd.microsoft.icon',
|
||||
'image/tiff',
|
||||
'image/tiff',
|
||||
'image/svg+xml',
|
||||
'image/svg+xml',
|
||||
'application/pdf',
|
||||
'image/vnd.adobe.photoshop',
|
||||
'application/postscript',
|
||||
'application/postscript',
|
||||
'application/postscript'
|
||||
);
|
||||
return $mime_types;
|
||||
}
|
||||
|
||||
public static function duplicateMysqlRow( $table, $id_field, $id, $leave = false )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$db -> query( "INSERT INTO " . $table . " (`" . $id_field . "`) VALUES (NULL)" );
|
||||
$newid = $db -> lastInsertId();
|
||||
|
||||
$sql = "UPDATE " . $table . " SET ";
|
||||
|
||||
$query = $db -> query( 'SELECT * FROM ' . $table . ' WHERE ' . $id_field . ' = ' . $id );
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch( PDO::FETCH_ASSOC ) )
|
||||
{
|
||||
foreach ( $row as $key => $value )
|
||||
{
|
||||
if ( $key != $id_field && @!in_array( $key, $leave ) )
|
||||
$sql .= '`' . $key . '` = "' . str_replace( '"', '\"', $value ) . '", ';
|
||||
}
|
||||
}
|
||||
$query -> closeCursor();
|
||||
|
||||
$sql = substr( $sql, 0, strlen( $sql ) - 2 );
|
||||
$sql .= " WHERE " . $id_field . " = " . $newid;
|
||||
|
||||
$db -> query( $sql );
|
||||
|
||||
return $newid;
|
||||
}
|
||||
|
||||
public static function copy_file( $url, $filename )
|
||||
{
|
||||
$file = fopen( $url, "rb" );
|
||||
if ( !$file ) return false; else
|
||||
{
|
||||
$fc = fopen( $filename, "wb" );
|
||||
while ( !feof( $file ) )
|
||||
{
|
||||
$line = fread( $file, 1028 );
|
||||
fwrite( $fc, $line );
|
||||
}
|
||||
fclose( $fc );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static function d2w( $digits )
|
||||
{
|
||||
if ( $digits*1 == 0 )
|
||||
{
|
||||
return "zero";
|
||||
}
|
||||
|
||||
$jednosci = Array( 'zero', 'jeden', 'dwa', 'trzy', 'cztery', 'pięć', 'sześć', 'siedem', 'osiem', 'dziewięć' );
|
||||
$dziesiatki = Array( '', 'dziesięć', 'dwadzieścia', 'trzydzieści', 'czterdzieści', 'piećdziesiąt', 'sześćdziesiąt', 'siedemdziesiąt', 'osiemdziesiąt', 'dziewiećdziesiąt' );
|
||||
$setki = Array( '', 'sto', 'dwieście', 'trzysta', 'czterysta', 'pięćset', 'sześćset', 'siedemset', 'osiemset', 'dziewięćset' );
|
||||
$nastki = Array( 'dziesięć', 'jedenaście', 'dwanaście', 'trzynaście', 'czternaście', 'piętnaście', 'szesnaście', 'siedemnaście', 'osiemnaście', 'dzięwietnaście' );
|
||||
$tysiace = Array( 'tysiąc', 'tysiące', 'tysięcy' );
|
||||
|
||||
$digits = (string) $digits;
|
||||
$digits = strrev( $digits );
|
||||
$i = strlen( $digits );
|
||||
$string = '';
|
||||
|
||||
if( $i > 5 && $digits[5] > 0 )
|
||||
{
|
||||
$string .= $setki[ $digits[5] ] . ' ';
|
||||
}
|
||||
if( $i > 4 && $digits[4] > 1 )
|
||||
{
|
||||
$string .= $dziesiatki[ $digits[4] ] . ' ';
|
||||
}
|
||||
else if( $i > 3 && $digits[4] == 1 )
|
||||
{
|
||||
$string .= $nastki[$digits[3]] . ' ';
|
||||
}
|
||||
if( $i > 3 && $digits[3] > 0 && $digits[4] != 1 )
|
||||
{
|
||||
$string .= $jednosci[ $digits[3] ] . ' ';
|
||||
}
|
||||
$tmpStr = substr( strrev( $digits ), 0, -3 );
|
||||
if( strlen( $tmpStr ) > 0 )
|
||||
{
|
||||
$tmpInt = (int) $tmpStr;
|
||||
if( $tmpInt == 1 )
|
||||
{
|
||||
$string .= $tysiace[0] . ' ';
|
||||
}
|
||||
elseif( ( $tmpInt % 10 > 1 && $tmpInt % 10 < 5 ) && ( $tmpInt < 10 || $tmpInt > 20 ) )
|
||||
{
|
||||
$string .= $tysiace[1] . ' ';
|
||||
}
|
||||
else
|
||||
{
|
||||
$string .= $tysiace[2] . ' ';
|
||||
}
|
||||
}
|
||||
if( $i > 2 && $digits[2] > 0 )
|
||||
{
|
||||
$string .= $setki[$digits[2]] . ' ';
|
||||
}
|
||||
if( $i > 1 && $digits[1] > 1 )
|
||||
{
|
||||
$string .= $dziesiatki[$digits[1]] . ' ';
|
||||
}
|
||||
elseif( $i > 0 && $digits[1] == 1 )
|
||||
{
|
||||
$string .= $nastki[$digits[0]] . ' ';
|
||||
}
|
||||
if( $digits[0] > 0 && $digits[1] != 1 )
|
||||
{
|
||||
$string .= $jednosci[$digits[0]] . ' ';
|
||||
}
|
||||
return $string;
|
||||
}
|
||||
|
||||
public static function slownie($a,$j1,$j2,$j3)
|
||||
{
|
||||
$out = self::d2w($a);
|
||||
$i = strlen($a);
|
||||
$l = substr($a,$i-1);
|
||||
if ( $l == 1 )
|
||||
{
|
||||
$out .= " $j1";
|
||||
}
|
||||
else if ( $l == 2 || $l == 3 || $l == 4 )
|
||||
{
|
||||
$out .= " $j2";
|
||||
}
|
||||
else
|
||||
{
|
||||
$out .= " $j3";
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
|
||||
public static function SC($a)
|
||||
{
|
||||
$a = round($a,2);
|
||||
$c = floor($a);
|
||||
$u = $a - $c;
|
||||
$us = self::slownie(round($u*100,2),"grosz","grosze","groszy");
|
||||
$cs = self::slownie($c,"złoty","złote","złotych");
|
||||
return "$cs, $us";
|
||||
}
|
||||
|
||||
public static function downloadFile( $id )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'SELECT file FROM pp_articles_file WHERE id = :id' );
|
||||
$query -> bindValue( ':id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
if (file_exists( $row['file'] ) )
|
||||
{
|
||||
header( 'Content-Description: File Transfer');
|
||||
header( 'Content-Type: application/octet-stream');
|
||||
header( 'Content-Disposition: attachment; filename=' . basename( $row['file'] ) );
|
||||
header( 'Content-Transfer-Encoding: binary');
|
||||
header( 'Expires: 0');
|
||||
header( 'Cache-Control: must-revalidate, post-check=0, pre-check=0');
|
||||
header( 'Pragma: public');
|
||||
header( 'Content-Length: ' . filesize( $row['file'] ) );
|
||||
ob_clean();
|
||||
flush();
|
||||
readfile( $row['file'] );
|
||||
exit;
|
||||
}
|
||||
}
|
||||
$query -> closeCursor();
|
||||
}
|
||||
|
||||
public static function isBot( $user_agent = '' )
|
||||
{
|
||||
if ( !$user_agent )
|
||||
$user_agent = $_SERVER['HTTP_USER_AGENT'];
|
||||
|
||||
$bots = array( "Teoma", "alexa", "froogle", "Gigabot", "inktomi", "looksmart", "URL_Spider_SQL", "Firefly", "NationalDirectory", "Ask Jeeves", "TECNOSEEK", "InfoSeek", "WebFindBot", "girafabot",
|
||||
"crawler", "www.galaxy.com", "Googlebot", "Scooter", "Slurp", "msnbot", "appie", "FAST", "WebBug", "Spade", "ZyBorg", "rabaz", "Baiduspider", "Feedfetcher-Google", "TechnoratiSnoop", "Rankivabot",
|
||||
"Mediapartners-Google", "Sogou web spider", "WebAlta Crawler","TweetmemeBot", "Butterfly", "Twitturls", "Me.dium", "Twiceler");
|
||||
|
||||
if ( is_array( $bots ) ) foreach ( $bots as $bot )
|
||||
{
|
||||
if ( strpos( $user_agent, $bot ) !== false )
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function otherDiffDate( $start, $end, $out_in_array = false )
|
||||
{
|
||||
$intervalo = date_diff( date_create( $start ), date_create( $end ) );
|
||||
$out = $intervalo -> format( "Years:%Y,Months:%M,Days:%d,Hours:%H,Minutes:%i,Seconds:%s" );
|
||||
if ( !$out_in_array )
|
||||
return $out;
|
||||
$a_out = array();
|
||||
array_walk( explode( ',', $out ),
|
||||
function($val,$key) use(&$a_out){
|
||||
$v=explode(':',$val);
|
||||
$a_out[$v[0]] = $v[1];
|
||||
});
|
||||
return $a_out;
|
||||
}
|
||||
|
||||
public static function getHost( $page, $www = true )
|
||||
{
|
||||
preg_match('@^(?:http://)?([^/]+)@i', $page, $matches);
|
||||
if ( !$www )
|
||||
$matches[1] = str_replace("www.", "", $matches[1]);
|
||||
return $matches[1];
|
||||
}
|
||||
|
||||
public static function checkEmailRegister( $email )
|
||||
{
|
||||
if ( !self::checkEmail( $email ) )
|
||||
return 1;
|
||||
else
|
||||
{
|
||||
if ( \admin\factory\Restriction::isBannedEmail( $email ) || !self::isEmailFree( $email ) )
|
||||
return 2;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static function checkPasswordRegister( $password , $password2 )
|
||||
{
|
||||
if ( strlen( $password ) < 5 )
|
||||
return 1;
|
||||
else
|
||||
{
|
||||
if ( $password != $password2 )
|
||||
return 2;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static function checkLoginRegister( $login )
|
||||
{
|
||||
if ( strlen( $login ) < 5 || preg_match( "/[^A-z0-9_-]/" , $login ) )
|
||||
return 1;
|
||||
else
|
||||
{
|
||||
if ( \admin\factory\Restriction::isBannedLogin( $login ) || !self::isLoginFree( $login ) )
|
||||
return 2;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
function importDumpFile( $filePath )
|
||||
{
|
||||
global $db;
|
||||
|
||||
if (!is_file($filePath))
|
||||
throw new Exception("Podany plik ($filePath) nie istniej!!");
|
||||
|
||||
$lines = file( $filePath );
|
||||
$query = '';
|
||||
foreach ( $lines as $line )
|
||||
{
|
||||
if( strncmp($line,'--',2) == 0 )
|
||||
continue;
|
||||
if( strncmp($line,'/*',2) == 0 )
|
||||
continue;
|
||||
|
||||
$line = ' '.trim($line);
|
||||
$query .= $line;
|
||||
|
||||
if( $line[strlen($line) - 1] == ';' )
|
||||
{
|
||||
$db -> query( $query );
|
||||
$query = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function getFormatDate()
|
||||
{
|
||||
$date = date("l, d-F-Y", time());
|
||||
$date_ang = array('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday', 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
|
||||
$date_pl = array('Poniedziałek', 'Wtorek', 'Środa', 'Czwartek', 'Piątek', 'Sobota', 'Niedziela', 'Styczeń', 'Luty', 'Marzec', 'Kwiecień', 'Maj', 'Czerwiec', 'Lipiec', 'Sierpień', 'Wrzesień', 'Październik', 'Listopad', 'Grudzień');
|
||||
$data = str_replace($date_ang, $date_pl, $date);
|
||||
$data = str_replace('-',' ',$data);
|
||||
return $data;
|
||||
}
|
||||
|
||||
public static function getNameDay()
|
||||
{
|
||||
if ( file_exists( 'resources/namedays.php' ) )
|
||||
{
|
||||
include 'resources/namedays.php';
|
||||
|
||||
$days = explode( "*" , $namedays );
|
||||
$today = date('d m');
|
||||
for ( $x = 0; $x < sizeof( $days ); $x++ ) {
|
||||
$day = explode( "-" , $days[$x] );
|
||||
if ( $today == trim( $day[0] ) )
|
||||
$out = $day[1];
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
|
||||
public static function setSessionVar( $var, $val, $admin = false )
|
||||
{
|
||||
if ( !$admin )
|
||||
$_SESSION[ $var ] = $val;
|
||||
else
|
||||
$_SESSION[ 'admin_' . $var ] = $val;
|
||||
}
|
||||
|
||||
public static function getSessionVar( $var, $admin = false )
|
||||
{
|
||||
if ( !$admin )
|
||||
{
|
||||
if ( isset( $_SESSION[ $var ] ) )
|
||||
return $_SESSION[ $var ];
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( isset( $_SESSION[ 'admin_' . $var ] ) )
|
||||
return $_SESSION[ 'admin_' . $var ];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function deleteSessionVar( $var, $admin = false )
|
||||
{
|
||||
if ( !$admin )
|
||||
unset( $_SESSION[ $var ] );
|
||||
else
|
||||
unset( $_SESSION[ 'admin_' . $var ] );
|
||||
}
|
||||
|
||||
public static function saveString( $val, $tolower = false )
|
||||
{
|
||||
if ( $tolower )
|
||||
$val = strtolower($val);
|
||||
return trim( strip_tags( $val ) );
|
||||
}
|
||||
|
||||
public static function formGetHash( $val )
|
||||
{
|
||||
$val = base64_encode( $val );
|
||||
$val = self::formGet( $val );
|
||||
return base64_decode( $val );
|
||||
}
|
||||
|
||||
public static function formGet( $var )
|
||||
{
|
||||
$out = '';
|
||||
if ( isset( $_POST[ $var ] ) )
|
||||
{
|
||||
if ( is_string( $_POST[ $var ] ) )
|
||||
$out = trim( $_POST[ $var ] );
|
||||
else
|
||||
$out = $_POST[ $var ];
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( isset( $_GET[ $var ] ) )
|
||||
{
|
||||
if ( is_string( $_GET[ $var ] ) )
|
||||
$out = trim( $_GET[ $var ] );
|
||||
else
|
||||
$out = $_GET[ $var ];
|
||||
}
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
|
||||
public static function formGetInt( $var )
|
||||
{
|
||||
return (int)self::formGet( $var );
|
||||
}
|
||||
|
||||
public static function setAlert( $val )
|
||||
{
|
||||
self::setSessionVar( 'alert', $val );
|
||||
}
|
||||
|
||||
public static function pre( $data , $type = '' )
|
||||
{
|
||||
$data = str_replace( 'Array
|
||||
(' , '' , $data );
|
||||
$data = str_replace( ')' , '' , $data );
|
||||
|
||||
echo '<pre';
|
||||
if ( $type == 'error' )
|
||||
echo ' style="color: #cc0000;" ';
|
||||
else if ( $type == 'info' )
|
||||
echo ' style="color: #2c539e;" ';
|
||||
else
|
||||
echo ' style="color: #8fc400;" ';
|
||||
echo '>' . print_r( $data , true ) . '</pre>';
|
||||
}
|
||||
|
||||
public static function getComboYesNo()
|
||||
{
|
||||
$tab[0] = 'nie';
|
||||
$tab[1] = 'tak';
|
||||
|
||||
return $tab;
|
||||
}
|
||||
|
||||
public static function deleteAction()
|
||||
{
|
||||
$akcja = "$.prompt( 'Na pewno chcesz usunąć wybrany element?', { title: 'Potwierdź?', submit: function(e,v,m,f) { if ( v == true ) document.location.href='index.php?rw=del&id=[param]'; }, buttons: { 'tak': true, 'nie': false }, focus: 1 } )";
|
||||
$akcja = 'onClick="' . $akcja . '"';
|
||||
|
||||
return $akcja;
|
||||
}
|
||||
|
||||
public static function getPagingVar( $var, $bs, $ls )
|
||||
{
|
||||
if ( $var == 'a' )
|
||||
{
|
||||
if ( $bs == 1 )
|
||||
return 6;
|
||||
else if ( $bs == 2 )
|
||||
return 5;
|
||||
else if ( $bs == 3 )
|
||||
return 4;
|
||||
else
|
||||
return 3;
|
||||
}
|
||||
else if ( $var == 'b' )
|
||||
{
|
||||
if ( $bs == $ls )
|
||||
return 6;
|
||||
else if ( $bs == $ls-1 )
|
||||
return 5;
|
||||
else if ( $bs == $ls-2 )
|
||||
return 4;
|
||||
else
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
|
||||
public static function checkBrowseLimit( $limit )
|
||||
{
|
||||
switch ($limit)
|
||||
{
|
||||
case 5:
|
||||
return 5;
|
||||
break;
|
||||
case 10:
|
||||
return 10;
|
||||
break;
|
||||
case 25:
|
||||
return 25;
|
||||
break;
|
||||
case 50:
|
||||
return 50;
|
||||
break;
|
||||
case 100:
|
||||
return 100;
|
||||
break;
|
||||
default:
|
||||
return 25;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static function getPagesTitle()
|
||||
{
|
||||
global $cache , $config , $db;
|
||||
|
||||
$key = 'getPagesTitle:all';
|
||||
|
||||
if ( !$pages = $cache -> fetch( $key ) )
|
||||
{
|
||||
$query = $db -> prepare( 'SELECT id FROM pp_pages' );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
$pages[ $row['id'] ] = \admin\factory\Pages::getPageTitle( $row['id'] );
|
||||
$query -> closeCursor();
|
||||
$cache -> store( $key , $pages , $config['cache_expire_short'] );
|
||||
}
|
||||
|
||||
return $pages;
|
||||
}
|
||||
|
||||
public static function rewriteHtacces()
|
||||
{
|
||||
global $db , $config;
|
||||
|
||||
$link_base = "http://" . $_SERVER['SERVER_NAME'] . "/";
|
||||
|
||||
$nl = chr( 13 ) . chr( 10 );
|
||||
$rss_tmp = '';
|
||||
|
||||
$site_map = '<?xml version="1.0" encoding="UTF-8"?>' . $nl;
|
||||
$site_map .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . $nl;
|
||||
$site_map .= '<url>' . $nl;
|
||||
$site_map .= '<loc>' . $link_base . '</loc>' . $nl;
|
||||
$site_map .= '<lastmod>' . date( 'Y-m-d' ) . '</lastmod>' . $nl;
|
||||
$site_map .= '<changefreq>daily</changefreq>' . $nl;
|
||||
$site_map .= '<priority>1</priority>' . $nl;
|
||||
$site_map .= '</url>' . $nl;
|
||||
|
||||
$htaccess_data = file_get_contents( '../files/htaccess.conf' );
|
||||
$htaccess_data = str_replace( '{MAIN_PAGE}' , self::getMainPage() , $htaccess_data );
|
||||
$htaccess_data = str_replace( '{PAGE}' , $config['page'] , $htaccess_data );
|
||||
|
||||
$query = $db -> prepare( 'SELECT id, name FROM pp_langs WHERE enabled = :enabled' );
|
||||
$query -> bindValue( ':enabled', 1, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
$query2 = $db -> prepare( 'SELECT title, seo_link, page_id FROM pp_pages_langs WHERE lang_id = :lang_id' );
|
||||
$query2 -> bindValue( ':lang_id' , $row['id'] , \PDO::PARAM_STR );
|
||||
$query2 -> execute();
|
||||
if ( $query2 -> rowCount() ) while ( $row2 = $query2 -> fetch() )
|
||||
{
|
||||
$site_map .= '<url>' . $nl;
|
||||
if ( !$row2['seo_link'] )
|
||||
$site_map .= '<loc>' . $link_base . 's,' . $row2['page_id'] . ',' . self::seo( $row2['title'] ) . '</loc>' . $nl;
|
||||
else
|
||||
$site_map .= '<loc>' . $link_base . $row['seo_link'] . '</loc>' . $nl;
|
||||
$site_map .= '<lastmod>' . date( 'Y-m-d' ) . '</lastmod>' . $nl;
|
||||
$site_map .= '<changefreq>daily</changefreq>' . $nl;
|
||||
$site_map .= '<priority>1</priority>' . $nl;
|
||||
$site_map .= '</url>' . $nl;
|
||||
|
||||
if ( $row2['seo_link'] )
|
||||
{
|
||||
$htaccess_data .= chr( 13 ) . chr( 10 ) . 'RewriteCond %{QUERY_STRING} !=""';
|
||||
$htaccess_data .= chr( 13 ) . chr( 10 ) . 'RewriteCond %{REQUEST_METHOD} !=POST';
|
||||
$htaccess_data .= chr( 13 ) . chr( 10 ) . 'RewriteRule ' . \System::seo( $row2['seo_link'] ) . ' %{REQUEST_URI}? [R=301,L]';
|
||||
$htaccess_data .= chr( 13 ) . chr( 10 ) . 'RewriteRule ^' . \System::seo( $row2['seo_link'] ) . '$ index.php?rw=change_site&id=' . $row2['page_id'] . ' [L]';
|
||||
}
|
||||
}
|
||||
|
||||
$query2 = $db -> prepare( 'SELECT title, article_id, seo_link FROM pp_articles_langs WHERE lang_id = :lang_id' );
|
||||
$query2 -> bindValue( ':lang_id' , $row['id'] , \PDO::PARAM_STR );
|
||||
$query2 -> execute();
|
||||
if ( $query2 -> rowCount() ) while ( $row2 = $query2 -> fetch() )
|
||||
{
|
||||
$site_map .= '<url>' . $nl;
|
||||
if ( !$row2['seo_link'] )
|
||||
$site_map .= '<loc>' . $link_base . 'a,' . $row2['article_id'] . ',' . self::seo( $row2['title'] ) . '</loc>' . $nl;
|
||||
else
|
||||
$site_map .= '<loc>' . $link_base . $row2['seo_link'] . '</loc>' . $nl;
|
||||
$site_map .= '<lastmod>' . date( 'Y-m-d' , strtotime( self::getDate() ) ) . '</lastmod>' . $nl;
|
||||
$site_map .= '<changefreq>daily</changefreq>' . $nl;
|
||||
$site_map .= '<priority>1</priority>' . $nl;
|
||||
$site_map .= '</url>' . $nl;
|
||||
|
||||
if ( $row2['seo_link'] )
|
||||
{
|
||||
$htaccess_data .= chr( 13 ) . chr( 10 ) . 'RewriteCond %{QUERY_STRING} !=""';
|
||||
$htaccess_data .= chr( 13 ) . chr( 10 ) . 'RewriteCond %{REQUEST_METHOD} !=POST';
|
||||
$htaccess_data .= chr( 13 ) . chr( 10 ) . 'RewriteRule ' . \System::seo( $row2['seo_link'] ) . ' %{REQUEST_URI}? [R=301,L]';
|
||||
$htaccess_data .= chr( 13 ).chr( 10 ) . 'RewriteRule ^' . \System::seo( $row2['seo_link'] ) . '$ index.php?art=$1' . $row2['article_id'] . ' [L]';
|
||||
}
|
||||
}
|
||||
$query2 -> closeCursor();
|
||||
|
||||
$query2 = $db -> prepare( 'SELECT title, article_id, text, seo_link FROM pp_articles_langs WHERE lang_id = :lang_id ORDER BY article_id DESC LIMIT 30' );
|
||||
$query2 -> bindValue( ':lang_id' , $row['id'] , \PDO::PARAM_STR );
|
||||
$query2 -> execute();
|
||||
if ( $query2 -> rowCount() ) while ( $row2 = $query2 -> fetch() )
|
||||
{
|
||||
$rss_tmp .= '<item>' . $nl;
|
||||
$rss_tmp .= '<title>' . $row2['title'] . '</title>' . $nl;
|
||||
if ( !$row2['seo_link'] )
|
||||
$rss_tmp .= '<link>' . $link_base . 'a,' . $row2['article_id'] . ',' . self::seo( $row2['title'] ) . '</link>' . $nl;
|
||||
else
|
||||
$rss_tmp .= '<link>' . $link_base . $row2['seo_link'] . '</link>' . $nl;
|
||||
$text = str_replace( 'ó' , 'ó' , stripslashes( $row2['text'] ) );
|
||||
$text = str_replace( 'ó' , 'ó' , $text );
|
||||
$text = System::deleteHTML( $text );
|
||||
$text = mb_substr( $text , 0 , 150 , 'UTF-8' );
|
||||
$rss_tmp .= '<description>' . $text . '...</description>' . $nl;
|
||||
$rss_tmp .= '<pubDate>' . date( "d/m/Y H:i" , strtotime( self::getDate() ) ) . '</pubDate>' . $nl;
|
||||
$rss_tmp .= '</item>' . $nl;
|
||||
}
|
||||
$query2 -> closeCursor();
|
||||
}
|
||||
$query -> closeCursor();
|
||||
|
||||
$site_map .= '</urlset>';
|
||||
|
||||
$htaccess = '../.htaccess';
|
||||
$fp = fopen( $htaccess , 'w' );
|
||||
fwrite( $fp , $htaccess_data );
|
||||
fclose( $fp );
|
||||
|
||||
$sitemap = '../files/sitemap.xml';
|
||||
$fp = fopen( $sitemap , 'w' );
|
||||
fwrite( $fp , $site_map );
|
||||
fclose( $fp );
|
||||
|
||||
$rss_feed = '<?xml version="1.0" encoding="UTF-8"?>' . $nl;
|
||||
$rss_feed .= '<rss version="2.0">' . $nl;
|
||||
$rss_feed .= '<channel>' . $nl;
|
||||
$rss_feed .= '<title>' . \admin\factory\Settings::getSystemSettings( 'firm_name' ) . '</title>' . $nl;
|
||||
$rss_feed .= '<link>' . $link_base . '</link>' . $nl;
|
||||
$rss_feed .= '<description></description>' . $nl;
|
||||
$rss_feed .= '<language>pl</language>';
|
||||
$rss_feed .= '<copyright>Copyright © ' . \admin\factory\Settings::getSystemSettings('firm_name') . '</copyright>' . $nl;
|
||||
$rss_feed .= '<lastBuildDate>' . date( 'm/d/Y H:i' , strtotime( self::getDate() ) ) . '</lastBuildDate>' . $nl;
|
||||
$rss_feed .= $rss_tmp;
|
||||
$rss_feed .= '</channel>' . $nl;
|
||||
$rss_feed .= '</rss>' . $nl;
|
||||
|
||||
|
||||
$rssfeed = '../files/rss.xml';
|
||||
$fp = fopen( $rssfeed , 'w' );
|
||||
fwrite( $fp , $rss_feed );
|
||||
fclose( $fp );
|
||||
}
|
||||
|
||||
function deleteHTML( $text )
|
||||
{
|
||||
$search = array ("'<script[^>]*?>.*?</script>'si",
|
||||
"'<[/!]*?[^<>]*?>'si",
|
||||
"'([rn])[s]+'",
|
||||
"'&(quot|#34);'i",
|
||||
"'&(amp|#38);'i",
|
||||
"'&(lt|#60);'i",
|
||||
"'&(gt|#62);'i",
|
||||
"'&(nbsp|#160);'i",
|
||||
"'&(iexcl|#161);'i",
|
||||
"'&(cent|#162);'i",
|
||||
"'&(pound|#163);'i",
|
||||
"'&(copy|#169);'i",
|
||||
"'&#(d+);'e");
|
||||
|
||||
$replace = array ("",
|
||||
"",
|
||||
"\1",
|
||||
"\"",
|
||||
"&",
|
||||
"<",
|
||||
">",
|
||||
" ",
|
||||
chr(161),
|
||||
chr(162),
|
||||
chr(163),
|
||||
chr(169),
|
||||
"chr(\1)");
|
||||
|
||||
$text = preg_replace($search, $replace, $text);
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
public static function getMainPage()
|
||||
{
|
||||
global $db , $cache , $config, $lang;
|
||||
|
||||
$key = 'mainPage:' . $lang -> get_language();
|
||||
|
||||
if ( !$main_page = $cache -> fetch( $key . 'a' ) )
|
||||
{
|
||||
$query = $db -> prepare( 'SELECT pp.id, seo_link FROM pp_pages AS pp, pp_pages_langs AS ppt WHERE enabled = :enabled AND pp.id = ppt.page_id AND lang_id = :lang_id ORDER BY id_menu ASC, o ASC LIMIT 1' );
|
||||
$query -> bindValue( ':enabled', 1, \PDO::PARAM_STR );
|
||||
$query -> bindValue( ':lang_id', $lang -> get_language(), \PDO::PARAM_STR );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
if ( $row['seo_link'] )
|
||||
$main_page = $row['seo_link'];
|
||||
else
|
||||
$main_page = 's,' . $row['id'] . ',' . self::seo( \admin\factory\Pages::getPageTitle ( $row[ 'id' ] ) );
|
||||
}
|
||||
$query -> closeCursor();
|
||||
$cache -> store( $key , $main_page , $config['cache_expire'] );
|
||||
}
|
||||
|
||||
return $main_page;
|
||||
}
|
||||
|
||||
public static function seo( $val )
|
||||
{
|
||||
$array_rep1 = array( '*', '_', ' ', '/', '+', '"', "'", '?', '-', ',', '!', '~', '<', '>', '@', '#', '$', '%', '^', '&', '*'. '(', ')'. '-', '=', '\\', '|', '[', ']', '/', ':' );
|
||||
$array_rep2 = array( '-', '-', '-', '-', '-', '', '', '', '-', '-', '', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '', '-', '-', '=', '-', '-', '-', '-' );
|
||||
|
||||
$val = self::noPl( $val );
|
||||
$val = str_replace( $array_rep1 , $array_rep2 , $val );
|
||||
$val = strtolower( $val );
|
||||
$val = preg_replace( '/(-){2,}/', '-', $val );
|
||||
|
||||
return $val;
|
||||
}
|
||||
|
||||
public static function noPL( $val )
|
||||
{
|
||||
$table = Array(
|
||||
//WIN
|
||||
"\xb9" => "a", "\xa5" => "A", "\xe6" => "c", "\xc6" => "C",
|
||||
"\xea" => "e", "\xca" => "E", "\xb3" => "l", "\xa3" => "L",
|
||||
"\xf3" => "o", "\xd3" => "O", "\x9c" => "s", "\x8c" => "S",
|
||||
"\x9f" => "z", "\xaf" => "Z", "\xbf" => "z", "\xac" => "Z",
|
||||
"\xf1" => "n", "\xd1" => "N",
|
||||
//UTF
|
||||
"\xc4\x85" => "a", "\xc4\x84" => "A", "\xc4\x87" => "c", "\xc4\x86" => "C",
|
||||
"\xc4\x99" => "e", "\xc4\x98" => "E", "\xc5\x82" => "l", "\xc5\x81" => "L",
|
||||
"\xc3\xb3" => "o", "\xc3\x93" => "O", "\xc5\x9b" => "s", "\xc5\x9a" => "S",
|
||||
"\xc5\xbc" => "z", "\xc5\xbb" => "Z", "\xc5\xba" => "z", "\xc5\xb9" => "Z",
|
||||
"\xc5\x84" => "n", "\xc5\x83" => "N",
|
||||
//ISO
|
||||
"\xb1" => "a", "\xa1" => "A", "\xe6" => "c", "\xc6" => "C",
|
||||
"\xea" => "e", "\xca" => "E", "\xb3" => "l", "\xa3" => "L",
|
||||
"\xf3" => "o", "\xd3" => "O", "\xb6" => "s", "\xa6" => "S",
|
||||
"\xbc" => "z", "\xac" => "Z", "\xbf" => "z", "\xaf" => "Z",
|
||||
"\xf1" => "n", "\xd1" => "N");
|
||||
|
||||
return strtr( $val , $table );
|
||||
}
|
||||
|
||||
public static function getDate()
|
||||
{
|
||||
return date( 'Y-m-d H:i:s' );
|
||||
}
|
||||
|
||||
public static function getArticlesTitle()
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'SELECT id FROM pp_articles' );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
$articles[ $row['id'] ] = \System::getArticleTitle( $row['id'] );
|
||||
$query -> closeCursor();
|
||||
|
||||
return $articles;
|
||||
}
|
||||
|
||||
public static function getArticleTitle( $id , $language = 'pl' )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'SELECT title FROM pp_articles_langs WHERE article_id = :article_id AND lang_id = :lang_id' );
|
||||
$query -> bindValue( ':article_id' , $id , PDO::PARAM_INT );
|
||||
$query -> bindValue( ':lang_id' , $language , PDO::PARAM_STR );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
$title = $row['title'];
|
||||
$query -> closeCursor();
|
||||
|
||||
if ( !$title )
|
||||
{
|
||||
$query2 = $db -> prepare( 'SELECT title FROM pp_articles_langs WHERE article_id = :article_id LIMIT 1' );
|
||||
$query2 -> bindValue( ':article_id' , $id , PDO::PARAM_STR );
|
||||
$query2 -> execute();
|
||||
if ( $query2 -> rowCount() ) while ( $row2 = $query2 -> fetch() )
|
||||
$title = $row2['title'];
|
||||
$query2 -> closeCursor();
|
||||
}
|
||||
return $title;
|
||||
}
|
||||
|
||||
public static function deleteCacheAdmin( $str = 'temp/' )
|
||||
{
|
||||
if( is_file( $str ) )
|
||||
return @unlink( $str );
|
||||
else if ( is_dir( $str ) )
|
||||
{
|
||||
$scan = glob( rtrim( $str , '/' ) . '/*' );
|
||||
if ( is_array( $scan ) ) foreach( $scan as $index => $path )
|
||||
self::deleteCacheAdmin( $path );
|
||||
if ( $str != 'temp/' && $str != 'admin/temp/' && is_dir( $str ) && self::isEmptyDir( $str ) )
|
||||
return @rmdir( $str );
|
||||
}
|
||||
self::deleteCache();
|
||||
}
|
||||
|
||||
public static function isEmptyDir($dir)
|
||||
{
|
||||
return (($files = @scandir($dir)) && count($files) <= 2);
|
||||
}
|
||||
|
||||
public static function deleteCache( $str = '../temp/' )
|
||||
{
|
||||
if( is_file( $str ) )
|
||||
return @unlink( $str );
|
||||
else if( is_dir( $str ) )
|
||||
{
|
||||
$scan = glob( rtrim( $str , '/' ) . '/*' );
|
||||
if ( is_array( $scan ) ) foreach( $scan as $index => $path )
|
||||
self::deleteCache( $path );
|
||||
if ( $str != '../temp/' && $str != 'temp/' && is_dir( $str ) && self::isEmptyDir( $str ) )
|
||||
return @rmdir( $str );
|
||||
}
|
||||
}
|
||||
|
||||
public static function sendEmail( $email, $temat, $tresc, $replay = '', $file = '' )
|
||||
{
|
||||
if ( file_exists('resources/phpmailer/class.phpmailer.php') )
|
||||
require_once 'resources/phpmailer/class.phpmailer.php';
|
||||
if ( file_exists('../resources/phpmailer/class.phpmailer.php') )
|
||||
require_once'../resources/phpmailer/class.phpmailer.php';
|
||||
|
||||
if ( isset($email) && isset($temat) && isset($tresc) )
|
||||
{
|
||||
$admin_mail = \admin\factory\Settings::getSystemSettings( 'admin_email');
|
||||
$mail = new PHPMailer();
|
||||
$mail -> SMTPAuth = true;
|
||||
$mail -> Host = \admin\factory\Settings::getSystemSettings( 'email_host' );
|
||||
$mail -> Port = \admin\factory\Settings::getSystemSettings( 'email_port' );
|
||||
$mail -> Username = \admin\factory\Settings::getSystemSettings( 'email_login' );
|
||||
$mail -> Password = \admin\factory\Settings::getSystemSettings( 'email_password' );
|
||||
$mail -> CharSet = "UTF-8";
|
||||
if ( $replay == "" )
|
||||
{
|
||||
$mail -> AddReplyTo( $admin_mail , \admin\factory\Settings::getSystemSettings( 'firm_name' ) );
|
||||
$mail -> SetFrom( $admin_mail , \admin\factory\Settings::getSystemSettings( 'firm_name' ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$mail -> AddReplyTo( $replay , '' );
|
||||
$mail -> SetFrom( $replay , '' );
|
||||
}
|
||||
$mail -> AddAddress( $email , '' );
|
||||
$mail -> Subject = $temat;
|
||||
$mail -> Body = str_replace( '<br>' , chr(13).chr(10) , $tresc );
|
||||
if ( file_exists( $file ) )
|
||||
$mail -> AddAttachment($file);
|
||||
$mail -> IsHTML(true);
|
||||
$mail -> Send();
|
||||
}
|
||||
}
|
||||
|
||||
public static function getDateDiff( $data1 , $data2 , $rodz = '60' )
|
||||
{
|
||||
$d1_t = explode(' ',$data1);
|
||||
$d1_tt = explode('-',$d1_t[0]);
|
||||
$rok1 = $d1_tt[0];
|
||||
$mc1 = $d1_tt[1];
|
||||
$d1 = $d1_tt[2];
|
||||
$d1_tt = explode(':',$d1_t[1]);
|
||||
$g1 = $d1_tt[0];
|
||||
$m1 = $d1_tt[1];
|
||||
$s1 = $d1_tt[2];
|
||||
|
||||
$d2_t = explode(' ',$data2);
|
||||
$d2_tt = explode('-',$d2_t[0]);
|
||||
$rok2 = $d2_tt[0];
|
||||
$mc2 = $d2_tt[1];
|
||||
$d2 = $d2_tt[2];
|
||||
$d2_tt = explode(':',$d2_t[1]);
|
||||
$g2 = $d2_tt[0];
|
||||
$m2 = $d2_tt[1];
|
||||
$s2 = $d2_tt[2];
|
||||
|
||||
$lt = mktime( $g2 , $m2 , $s2 , $mc2 , $d2 , $rok2 );
|
||||
$st = mktime( $g1 , $m1 , $s1 , $mc1 , $d1 , $rok1 );
|
||||
|
||||
return round( ( $lt - $st ) / $rodz );
|
||||
}
|
||||
|
||||
public static function checkEmail( $email )
|
||||
{
|
||||
if ( filter_var( $email , FILTER_VALIDATE_EMAIL ) )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function gen_hash( $limit = 5 )
|
||||
{
|
||||
$out = '';
|
||||
for ( $i = 0; $i < $limit; $i++ )
|
||||
$out .= chr( rand( 97 , 122 ) );
|
||||
return $out . rand( 1000 , 9999 );
|
||||
}
|
||||
|
||||
public static function isEmailFree( $email )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'SELECT id FROM pp_users WHERE email = :email' );
|
||||
$query -> bindValue( ':email', $email, \PDO::PARAM_STR );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() )
|
||||
return false;
|
||||
$query -> closeCursor();
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function isLoginFree( $login )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'SELECT id FROM pp_users WHERE login = :login' );
|
||||
$query -> bindValue( ':login', $login, \PDO::PARAM_STR );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() )
|
||||
return false;
|
||||
$query -> closeCursor();
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function getIp()
|
||||
{
|
||||
if ( isset( $_SERVER['HTTP_X_FORWARDED_FOR'] ) )
|
||||
return $_SERVER['HTTP_X_FORWARDED_FOR'];
|
||||
return $_SERVER['REMOTE_ADDR'];
|
||||
}
|
||||
|
||||
public static function random_color()
|
||||
{
|
||||
mt_srand((double)microtime()*1000000);
|
||||
$c = '';
|
||||
while(strlen($c)<6)
|
||||
$c .= sprintf("%02X", mt_rand(0, 255));
|
||||
return $c;
|
||||
}
|
||||
|
||||
public static function getRandomKeyWord( $keywords )
|
||||
{
|
||||
$out = '';
|
||||
|
||||
$keywords = explode( ',' , $keywords );
|
||||
|
||||
shuffle( $keywords );
|
||||
|
||||
for ( $i = 0; $i <= 1; $i++ )
|
||||
{
|
||||
if ( $out && $keywords[$i] )
|
||||
$out .= ', ';
|
||||
|
||||
$out .= $keywords[$i];
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
|
||||
public static function isImage( $file )
|
||||
{
|
||||
if ( $file['type'] == 'image/pjpeg' || $file['type'] == 'image/jpg' || $file['type'] == 'image/jpeg' || $file['type'] == 'image/gif' || $file['type'] == 'image/png' )
|
||||
{
|
||||
if ( $file['size'] < 500000 )
|
||||
{
|
||||
$x = getimagesize( $file['tmp_name'] );
|
||||
if ( is_array( $x ) && $x[0] > 0 && $x[1] > 0 )
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
67
autoload/front/controls/class.Page.php
Normal file
67
autoload/front/controls/class.Page.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
namespace front\controls;
|
||||
|
||||
class Page {
|
||||
|
||||
public static function checkUrlParams()
|
||||
{
|
||||
global $lang, $config;
|
||||
|
||||
$rw = \System::formGet( 'rw' );
|
||||
|
||||
switch ( $rw )
|
||||
{
|
||||
case 'send-ac-form':
|
||||
if ( $_SESSION['ac-check'] == $_POST['check'] || !$_POST['ac-name'] || !$_POST['ac-email'] || !$_POST['ac-text'] ):
|
||||
\System::setAlert( 'Brak wszystkich wymaganych danych.' );
|
||||
else:
|
||||
$tpl = new \Savant3;
|
||||
$tpl -> _data = $_POST;
|
||||
$out = $tpl -> fetch( 'other/contact-message' );
|
||||
|
||||
if ( ( !empty( $_FILES["ac-file"] ) ) && ( $_FILES['ac-file']['error'] == 0 ) )
|
||||
{
|
||||
$filename = basename( $_FILES['ac-file']['name'] );
|
||||
if ( in_array( $_FILES["ac-file"]["type"], \System::getImgFileTypes() ) )
|
||||
{
|
||||
$newname = 'temp/' . $filename;
|
||||
move_uploaded_file( $_FILES['ac-file']['tmp_name'], $newname );
|
||||
}
|
||||
}
|
||||
\System::sendEmail( \admin\factory\Settings::getSystemSettings( 'admin_email'), 'Wiadomość ze strony: www.' . $config['page'], $out, $replay = '', $newname );
|
||||
\System::setAlert( 'Wiadomość została wysłana.' );
|
||||
$_SESSION['ac-check'] = $_POST['check'];
|
||||
endif;
|
||||
break;
|
||||
|
||||
case 'change_language':
|
||||
$id = \System::formGet( 'id' );
|
||||
$lang = \language\FLanguage::loadLang( $id );
|
||||
\System::setSessionVar( 'lang' , $lang );
|
||||
break;
|
||||
|
||||
case 'change_site':
|
||||
if ( \System::formGet( 'type' ) )
|
||||
$site = \site\FSite::loadSiteStatic( \System::formGet( 'type' ) );
|
||||
else
|
||||
$site = new \site\Site( \System::formGetInt( 'id' ) );
|
||||
|
||||
\System::setSessionVar( 'site' , $site );
|
||||
break;
|
||||
|
||||
case 'add_comment':
|
||||
\article\FArticle::addComment( \System::formGetInt( 'article_id' ), \System::formGet( 'author' ), \System::formGet( 'text' ), \System::formGet( 'captcha_code' ), \System::formGet( 'check' ) );
|
||||
break;
|
||||
}
|
||||
|
||||
if ( \System::formGetInt( 'download' ) )
|
||||
\System::downloadFile( \System::formGetInt( 'download' ) );
|
||||
|
||||
if ( \System::formGet( 'account_activation' ) && \System::formGetInt( 'value' ) )
|
||||
\user\FUser::activateAccount( \System::saveString( \System::formGet( 'account_activation' ) ), \System::formGetInt( 'value' ) );
|
||||
|
||||
if ( \System::formGet( 'recover_password' ) && \System::formGetInt( 'value' ) )
|
||||
\user\FUser::recoverPassword( \System::saveString( \System::formGet( 'recover_password' ) ), \System::formGetInt( 'value' ) );
|
||||
}
|
||||
}
|
||||
?>
|
||||
152
autoload/front/factory/class.Page.php
Normal file
152
autoload/front/factory/class.Page.php
Normal file
@@ -0,0 +1,152 @@
|
||||
<?php
|
||||
namespace front\factory;
|
||||
|
||||
class Page {
|
||||
|
||||
const menu_pattern = '/MENU:[0-9]*/';
|
||||
const arts_list_pattern = '/ARTYKULY-LISTA:[0-9]*/';
|
||||
const lang_pattern = '/JEZYK:(.*)*]/';
|
||||
const container_pattern = '/KONTENER:[0-9]*/';
|
||||
|
||||
public static function convertPage( $layout )
|
||||
{
|
||||
global $site, $xajax, $config, $lang;
|
||||
|
||||
$art_id = \System::formGetInt( 'art' );
|
||||
|
||||
if ( $art_id )
|
||||
{
|
||||
$layout_id = \article\FArticle::getArticleLayoutId( $art_id );
|
||||
$layout = \admin\factory\Layouts::getLayout( $layout_id );
|
||||
}
|
||||
|
||||
$html = stripslashes( $layout['html'] );
|
||||
|
||||
if ( ( $config['dev'] or \System::formGet( 'dev' ) == true ) and file_exists( 'dev.html' ) )
|
||||
$html = file_get_contents ( 'dev.html' );
|
||||
|
||||
if ( \admin\factory\Settings::getSystemSettings( 'facebook_url' ) )
|
||||
$html = str_replace( '</body>', \site\VSite::getFacebookLikeBox() . '</body>', $html );
|
||||
|
||||
$html = str_replace( '[ALERT]', \site\VSite::drawAlert(), $html );
|
||||
$html = str_replace( '[COPYRIGHT]', \site\VSite::drawCopyright(), $html );
|
||||
$html = str_replace( '[BANERY]', \site\VSite::drawBanners(), $html );
|
||||
$html = str_replace( '[KONTAKT_MINI]', \site\VSite::drawContactMini(), $html );
|
||||
$html = str_replace( '[ZEGAR]', \site\VSite::drawClock(), $html );
|
||||
$html = str_replace( '[IMIENINY]', \site\VSite::drawNameDay(), $html );
|
||||
$html = str_replace( '[FORMULARZ_KONTAKTOWY]', \site\VSite::drawContactForm(), $html );
|
||||
$html = str_replace( '[WYSZUKIWARKA]', \site\VSite::drawSearchForm(), $html );
|
||||
$html = str_replace( '[REKLAMA]', \site\VSite::drawAdverts(), $html );
|
||||
$html = str_replace( '[PANEL_UZYTKOWNIKA]', \user\VUser::drawUserPanel(), $html );
|
||||
$html = str_replace( '[JEZYKI]', \language\VLanguage::showLanguages(), $html );
|
||||
$html = str_replace( '[NEWSLETTER]', \newsletter\VNewsletter::drawNewsletterSignForm(), $html );
|
||||
$html = str_replace( '[STRONA_GLOWNA]', \System::getMainPage(), $html );
|
||||
$html = str_replace( '[CSS]', stripslashes( $layout['css'] ), $html );
|
||||
$html = str_replace( '[JAVA_SCRIPT]', stripslashes( $layout['javascript'] ), $html );
|
||||
$html = str_replace( '[PAGE_ID]', $site -> _values['id'], $html );
|
||||
$html = str_replace( '[AJAX]', $xajax -> getJavascript( '../resources/xajax/' ), $html );
|
||||
$html = str_replace( '[LICZNIK_ODWIEDZIN]', \site\VSite::drawVisitCounter(), $html );
|
||||
|
||||
preg_match_all( self::lang_pattern, $html, $lang_t );
|
||||
if ( is_array( $lang_t[0] ) ) foreach( $lang_t[0] as $lang_tmp )
|
||||
{
|
||||
$lang_tmp = explode( ':', $lang_tmp );
|
||||
$lang_tmp = substr( $lang_tmp[1], 0, strlen( strip_tags( $lang_tmp[1] ) ) - 1 );
|
||||
$html = str_replace( '[JEZYK:' . $lang_tmp . ']', $lang -> getTrans( $lang_tmp ), $html );
|
||||
}
|
||||
|
||||
preg_match_all( self::menu_pattern, $html, $menu );
|
||||
if ( is_array( $menu[0] ) ) foreach( $menu[0] as $menu_tmp )
|
||||
{
|
||||
$menu_tmp = explode( ':', $menu_tmp );
|
||||
$html = str_replace( '[MENU:' . $menu_tmp[1] . ']', \menu\VMenu::show( $menu_tmp[1] ), $html );
|
||||
}
|
||||
|
||||
preg_match_all( self::arts_list_pattern, $html, $arts_list );
|
||||
if ( is_array( $arts_list[0] ) ) foreach( $arts_list[0] as $arts_list_tmp )
|
||||
{
|
||||
$arts_list_tmp = explode( ':', $arts_list_tmp );
|
||||
$html = str_replace( '[ARTYKULY-LISTA:' . $arts_list_tmp[1] . ']', \article\VArticle::drawArticleListStatic( $arts_list_tmp[1] ), $html );
|
||||
}
|
||||
|
||||
preg_match_all( self::container_pattern, $html, $container_list );
|
||||
if ( is_array( $container_list[0] ) ) foreach( $container_list[0] as $container_list_tmp )
|
||||
{
|
||||
$container_list_tmp = explode( ':', $container_list_tmp );
|
||||
$html = str_replace( '[KONTENER:' . $container_list_tmp[1] . ']', \site\VSite::drawStaticContainer( $container_list_tmp[1] ), $html );
|
||||
}
|
||||
|
||||
/* wyświetlenie artykułu i jego metadanych */
|
||||
if ( $art_id )
|
||||
{
|
||||
$article = \article\FArticle::loadArticle( $art_id );
|
||||
|
||||
if ( $article -> _values['meta_keywords'] )
|
||||
\System::setSessionVar( 'keywords', $article -> _values['meta_keywords'] );
|
||||
|
||||
if ( $article -> _values['meta_description'] )
|
||||
\System::setSessionVar( 'description', $article -> _values['meta_description'] );
|
||||
|
||||
$keywords = \System::getSessionVar( 'keywords' );
|
||||
$description = \System::getSessionVar( 'description' );
|
||||
|
||||
$site_title = \System::getRandomKeyWord( $keywords ) . ' • ' . $article -> _values['title']. ' • ' . \admin\factory\Settings::getSystemSettings( 'firm_name' );
|
||||
$html = str_replace( '[ZAWARTOSC]', \article\VArticle::draw( $art_id ), $html );
|
||||
}
|
||||
/* wyświetlenie pozostałych rzeczy i ich metadanych */
|
||||
else
|
||||
{
|
||||
if ( $site -> _values['meta_keywords'] != '' )
|
||||
\System::setSessionVar( 'keywords', $site -> _values['meta_keywords'] );
|
||||
|
||||
if ( $site -> _values['meta_description'] != '' )
|
||||
\System::setSessionVar( 'description', $site -> _values['meta_description'] );
|
||||
|
||||
$keywords = \System::getSessionVar( 'keywords' );
|
||||
$description = \System::getSessionVar( 'description' );
|
||||
|
||||
$site_title = \System::getRandomKeyWord( $keywords ) . ' • ' . $site -> _values['title'] . ' • ' . \admin\factory\Settings::getSystemSettings( 'firm_name' );
|
||||
|
||||
if ( $site -> _values['meta_title'] )
|
||||
$site_title = $site -> _values['meta_title'];
|
||||
|
||||
$html = str_replace( '[ZAWARTOSC]', \site\FSite::getContent(), $html );
|
||||
}
|
||||
|
||||
if ( $site -> _values['show_title'] )
|
||||
$title = \site\VSite::drawTitle( $site -> _values['title'] );
|
||||
|
||||
if ( $art_id && $article -> _values['replace_menu_title'] )
|
||||
$title = \site\VSite::drawTitle( $article -> _values['title'] );
|
||||
|
||||
$keywords = \System::getSessionVar( 'keywords' );
|
||||
$description = \System::getSessionVar( 'description' );
|
||||
|
||||
$html = str_replace( '[TYTUL_STRONY]', $title, $html );
|
||||
$html = str_replace( '[TYTUL]', $site_title, $html );
|
||||
$html = str_replace( '[SLOWA_KLUCZOWE]', $keywords, $html );
|
||||
$html = str_replace( '[OPIS_STRONY]', $description, $html );
|
||||
|
||||
if ( strpos( $html, '[PHP]' ) !== false )
|
||||
{
|
||||
$text = explode( '[PHP]', $html );
|
||||
$before = $text[0];
|
||||
for ( $i = 1; $i < count( $text ); $i++ )
|
||||
{
|
||||
$temp = explode( '[/PHP]' , $text[$i] );
|
||||
$code = $temp[0];
|
||||
|
||||
ob_start();
|
||||
eval( $code );
|
||||
$out .= ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
$out .= $temp[1];
|
||||
}
|
||||
$html = $before . $out;
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
?>
|
||||
12
autoload/front/view/class.Page.php
Normal file
12
autoload/front/view/class.Page.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
namespace front\view;
|
||||
|
||||
class Page {
|
||||
|
||||
public static function show()
|
||||
{
|
||||
$layout = \admin\factory\Layouts::getActiveLayout();
|
||||
return \front\factory\Page::convertPage( $layout );
|
||||
}
|
||||
}
|
||||
?>
|
||||
68
autoload/guestbook/class.FGuestBook.php
Normal file
68
autoload/guestbook/class.FGuestBook.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
namespace guestbook;
|
||||
|
||||
class FGuestBook {
|
||||
|
||||
const iLimit = 10;
|
||||
|
||||
public function addEntry( $signature, $text )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'INSERT INTO pp_guest_book ( signature , text , date) VALUES ( :signature , :text , :date )' );
|
||||
$query -> bindValue( ':signature', $signature, \PDO::PARAM_STR );
|
||||
$query -> bindValue( ':text', $text, \PDO::PARAM_STR );
|
||||
$query -> bindValue( ':date', \System::getDate(), \PDO::PARAM_STR );
|
||||
$query -> execute();
|
||||
$query -> closeCursor();
|
||||
}
|
||||
|
||||
public function getLimit()
|
||||
{
|
||||
return self::iLimit;
|
||||
}
|
||||
|
||||
public function getEntries( $from , $to )
|
||||
{
|
||||
global $db , $cache , $config;
|
||||
|
||||
$key = "FGuestBook:getEntries:$from:$to";
|
||||
|
||||
if ( !$entries = $cache -> fetch ( $key ) )
|
||||
{
|
||||
$query = $db -> prepare( 'SELECT signature, text, date FROM pp_guest_book ORDER BY date DESC LIMIT ' . $from . ',' . $to );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
$entry['signature'] = $row['signature'];
|
||||
$entry['text'] = nl2br( $row['text'] );
|
||||
$entry['date'] = date( "d/m/Y H:i", strtotime( $row['date'] ) );
|
||||
$entries[] = $entry;
|
||||
}
|
||||
$cache -> store( $key, $entries, $config['cache_expire_short'] );
|
||||
}
|
||||
|
||||
return $entries;
|
||||
}
|
||||
|
||||
public function getCountEntries()
|
||||
{
|
||||
global $db, $cache, $config;
|
||||
|
||||
$key = 'FGuestBook:getCountEntries';
|
||||
|
||||
if ( !$count = $cache -> fetch( $key ) )
|
||||
{
|
||||
$query = $db -> prepare( 'SELECT COUNT(1) FROM pp_guest_book' );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
$count = $row[0];
|
||||
$query -> closeCursor();
|
||||
|
||||
$cache -> store( $key, $count, $config['cache_expire_short'] );
|
||||
}
|
||||
|
||||
return $count;
|
||||
}
|
||||
}
|
||||
?>
|
||||
13
autoload/guestbook/class.VGuestBook.php
Normal file
13
autoload/guestbook/class.VGuestBook.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
namespace guestbook;
|
||||
|
||||
class VGuestBook {
|
||||
|
||||
public function drawGuestBook( $aEntries )
|
||||
{
|
||||
$tpl = new \Savant3;
|
||||
$tpl -> _entries = $aEntries;
|
||||
return $tpl -> fetch( 'site-guest-book.php' );
|
||||
}
|
||||
}
|
||||
?>
|
||||
79
autoload/language/class.FLanguage.php
Normal file
79
autoload/language/class.FLanguage.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
namespace language;
|
||||
|
||||
class FLanguage {
|
||||
|
||||
public static function getLangs()
|
||||
{
|
||||
global $db, $cache, $config, $lang;
|
||||
|
||||
$key = 'getLangs';
|
||||
|
||||
if ( !$langs = $cache -> fetch( $key ) )
|
||||
{
|
||||
$query = $db -> prepare( 'SELECT id , name FROM pp_langs WHERE enabled=:enabled' );
|
||||
$query -> bindValue( ':enabled', 1, \PDO::PARAM_STR );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
$lg['id'] = $row['id'];
|
||||
$lg['name'] = $lang -> getTrans( $row['name'] );
|
||||
$langs[] = $lg;
|
||||
}
|
||||
$query -> closeCursor();
|
||||
$cache -> store( $key , $langs , $config['cache_expire_long' ] );
|
||||
}
|
||||
return $langs;
|
||||
}
|
||||
|
||||
public static function loadLang( $language_tmp = 'pl', $admin = false )
|
||||
{
|
||||
global $cache, $db, $config;
|
||||
|
||||
$language_tmp = \language\Flanguage::checkLangCorrection( $language_tmp );
|
||||
|
||||
$key = 'loadLang:' . $language_tmp;
|
||||
|
||||
if ( !$translation = $cache -> fetch( $key ) )
|
||||
{
|
||||
$query = $db -> prepare( 'SELECT text, ' . $language_tmp . ' FROM pp_langs_text' );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
$translation[ $row['text'] ] = $row[ $language_tmp ];
|
||||
$query -> closeCursor();
|
||||
$cache -> store( $key , $translation , $config['cache_expire_long' ] );
|
||||
}
|
||||
\System::setSessionVar( 'current_lang' , $language_tmp , $admin );
|
||||
|
||||
$language = new \language\Language( $language_tmp );
|
||||
$language -> set_translation( $translation );
|
||||
|
||||
return $language;
|
||||
}
|
||||
|
||||
private static function checkLangCorrection( $lang_check )
|
||||
{
|
||||
switch ( $lang_check )
|
||||
{
|
||||
case 'pl':
|
||||
return 'pl';
|
||||
break;
|
||||
case 'en':
|
||||
return 'en';
|
||||
break;
|
||||
case 'ru':
|
||||
return 'ru';
|
||||
break;
|
||||
case 'de':
|
||||
return 'de';
|
||||
break;
|
||||
case 'uk':
|
||||
return 'uk';
|
||||
break;
|
||||
default:
|
||||
return 'pl';
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
42
autoload/language/class.Language.php
Normal file
42
autoload/language/class.Language.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
namespace language;
|
||||
|
||||
class Language {
|
||||
|
||||
private $_translation;
|
||||
private $_language;
|
||||
|
||||
public function __construct( $var )
|
||||
{
|
||||
$this -> _language = $var;
|
||||
}
|
||||
|
||||
public function get_language()
|
||||
{
|
||||
return $this->_language;
|
||||
}
|
||||
|
||||
public function set_language($_language)
|
||||
{
|
||||
$this->_language = $_language;
|
||||
}
|
||||
|
||||
public function get_translation()
|
||||
{
|
||||
return $this->_translation;
|
||||
}
|
||||
|
||||
public function set_translation($_translation)
|
||||
{
|
||||
$this->_translation = $_translation;
|
||||
}
|
||||
|
||||
public function getTrans( $val )
|
||||
{
|
||||
if ( isset( $this -> _translation[ $val ] ) )
|
||||
return $this -> _translation[ $val ];
|
||||
else
|
||||
return $val;
|
||||
}
|
||||
}
|
||||
?>
|
||||
18
autoload/language/class.VLanguage.php
Normal file
18
autoload/language/class.VLanguage.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
namespace language;
|
||||
|
||||
class VLanguage {
|
||||
|
||||
public static function showLanguages()
|
||||
{
|
||||
$langs = \language\FLanguage::getLangs();
|
||||
$current_lang = \System::getSessionVar( 'current_lang' );
|
||||
|
||||
$tpl = new \Savant3;
|
||||
$tpl -> _langs = $langs;
|
||||
$tpl -> _current_lang = $current_lang;
|
||||
|
||||
return $tpl -> fetch( 'other/languages' );
|
||||
}
|
||||
}
|
||||
?>
|
||||
53
autoload/menu/class.FMenu.php
Normal file
53
autoload/menu/class.FMenu.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
namespace menu;
|
||||
|
||||
class FMenu {
|
||||
|
||||
public static function loadMenu( $id )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'SELECT * FROM pp_menu WHERE id = :id AND enabled = "1"' );
|
||||
$query -> bindValue( ':id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
$menu = new \menu\Menu;
|
||||
$menu -> set_id( $id );
|
||||
$menu -> set_sites( self::loadMenuPages( $id ) );
|
||||
$menu -> set_type( $row['type'] );
|
||||
}
|
||||
$query -> closeCursor();
|
||||
|
||||
return $menu;
|
||||
}
|
||||
|
||||
public static function loadMenuPages( $id, $parent_id = 0 )
|
||||
{
|
||||
global $db , $cache , $config;
|
||||
|
||||
|
||||
$current_lang = \System::getSessionVar( 'current_lang' );
|
||||
$key = 'loadMenu:' . $id . ':' . $current_lang . ':' . $parent_id;
|
||||
|
||||
if ( !$sites = $cache -> fetch( $key . 'a' ) )
|
||||
{
|
||||
$query = $db -> prepare( 'SELECT id FROM pp_pages WHERE id_menu = :id_menu AND enabled = :enabled AND parent_id = :parent_id ORDER BY o' );
|
||||
$query -> bindValue( ':id_menu', $id, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':enabled', 1, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':parent_id', $parent_id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while( $row = $query -> fetch() )
|
||||
{
|
||||
$site = new \site\Site( $row['id'] );
|
||||
$site -> _values['subpages'] = self::loadMenuPages( $id, $row['id'] );
|
||||
$sites[] = $site;
|
||||
}
|
||||
$query -> closeCursor();
|
||||
$cache -> store( $key , $sites , $config['cache_expire'] );
|
||||
}
|
||||
|
||||
return $sites;
|
||||
}
|
||||
}
|
||||
?>
|
||||
38
autoload/menu/class.Menu.php
Normal file
38
autoload/menu/class.Menu.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
namespace menu;
|
||||
|
||||
class Menu {
|
||||
|
||||
private $_sites;
|
||||
private $_id;
|
||||
private $_type;
|
||||
|
||||
public function get_type() {
|
||||
return $this->_type;
|
||||
}
|
||||
|
||||
public function set_type($_type) {
|
||||
$this->_type = $_type;
|
||||
}
|
||||
|
||||
public function get_sites()
|
||||
{
|
||||
return $this->_sites;
|
||||
}
|
||||
|
||||
public function set_sites($_sites)
|
||||
{
|
||||
$this->_sites = $_sites;
|
||||
}
|
||||
|
||||
public function get_id()
|
||||
{
|
||||
return $this->_id;
|
||||
}
|
||||
|
||||
public function set_id($_id)
|
||||
{
|
||||
$this->_id = $_id;
|
||||
}
|
||||
}
|
||||
?>
|
||||
24
autoload/menu/class.VMenu.php
Normal file
24
autoload/menu/class.VMenu.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
namespace menu;
|
||||
|
||||
class VMenu {
|
||||
|
||||
public static function drawSubpages( $pages, $menu_id , $step = 0, $type = 0 )
|
||||
{
|
||||
$tpl = new \Savant3;
|
||||
$tpl -> _pages = $pages;
|
||||
$tpl -> _menu_id = $menu_id;
|
||||
$tpl -> _step = $step;
|
||||
$tpl -> _type = $type;
|
||||
return $tpl -> fetch( 'menu/subpages' );
|
||||
}
|
||||
|
||||
public static function show( $id )
|
||||
{
|
||||
$tpl = new \Savant3;
|
||||
$tpl -> _menu = \menu\FMenu::loadMenu( $id );
|
||||
|
||||
return $tpl -> fetch( 'menu/pages' );
|
||||
}
|
||||
}
|
||||
?>
|
||||
41
autoload/newsletter/class.FNewsletter.php
Normal file
41
autoload/newsletter/class.FNewsletter.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
namespace newsletter;
|
||||
|
||||
class FNewsletter {
|
||||
|
||||
public function signEmail( $type, $email )
|
||||
{
|
||||
global $db;
|
||||
|
||||
if ( !\System::checkEmail( $email ) )
|
||||
return \System::setAlert( 'Podany adres email jest nieprawidłowy.' );
|
||||
|
||||
$query = $db -> prepare( 'SELECT id FROM pp_newsletter_emails WHERE email = :email' );
|
||||
$query -> bindValue( ':email', $email, \PDO::PARAM_STR );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() && $type )
|
||||
return \System::setAlert( 'Podany adres email jest już zapisany do Newslettera.' );
|
||||
else if ( $query -> rowCount() && !$type )
|
||||
{
|
||||
$query2 = $db -> prepare( 'DELETE FROM pp_newsletter_emails WHERE email = :email' );
|
||||
$query2 -> bindValue( ':email', $email, \PDO::PARAM_STR );
|
||||
$query2 -> execute();
|
||||
if ( $query2 -> rowCount() )
|
||||
return \System::setAlert( 'Podany adres email został usunięty z Newslettera.' );
|
||||
$query2 -> closeCursor();
|
||||
}
|
||||
else if ( !$query -> rowCount() && !$type )
|
||||
return \System::alert( 'Podany adres email nie jest zapisany do Newslettera.' );
|
||||
else if ( !$query -> rowCOunt() && $type )
|
||||
{
|
||||
$query2 = $db -> prepare( 'INSERT INTO pp_newsletter_emails ( email ) VALUES ( :email )' );
|
||||
$query2 -> bindValue( ':email', $email, \PDO::PARAM_STR );
|
||||
$query2 -> execute();
|
||||
if ( $query2 -> rowCount() )
|
||||
return \System::setAlert( 'Podany adres email został dodany do Newslettera.' );
|
||||
$query2 -> closeCursor();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
?>
|
||||
12
autoload/newsletter/class.VNewsletter.php
Normal file
12
autoload/newsletter/class.VNewsletter.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
namespace newsletter;
|
||||
|
||||
class VNewsletter {
|
||||
|
||||
public static function drawNewsletterSignForm()
|
||||
{
|
||||
$tpl = new \Savant3;
|
||||
return $tpl -> fetch( 'newsletter/sign-form' );
|
||||
}
|
||||
}
|
||||
?>
|
||||
497
autoload/opd.class.php
Normal file
497
autoload/opd.class.php
Normal file
@@ -0,0 +1,497 @@
|
||||
<?php
|
||||
// -------------------------------------------------------------------- //
|
||||
// Open Power Board //
|
||||
// Open Power Driver //
|
||||
// Copyright (c) 2005 OpenPB team, http://www.openpb.net/ //
|
||||
// -------------------------------------------------------------------- //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU Lesser General Public License as //
|
||||
// published by the Free Software Foundation; either version 2.1 of the //
|
||||
// License, or (at your option) any later version. //
|
||||
// -------------------------------------------------------------------- //
|
||||
//
|
||||
// $Id: opd.class.php 53 2006-05-04 07:57:03Z zyxist $
|
||||
|
||||
if(!defined('OPD_DIR'))
|
||||
{
|
||||
define('OPD_DIR', './');
|
||||
}
|
||||
define('OPD_VERSION', '0.4');
|
||||
define('OPD_CACHE_PREPARE', true);
|
||||
|
||||
require(OPD_DIR.'opd.statement.php');
|
||||
|
||||
function opdErrorHandler(PDOException $exc)
|
||||
{
|
||||
echo '<br/><b>Open Power Driver internal error #'.$exc->getCode().': </b> '.$exc->getMessage().'<br/>
|
||||
Query used: <i>'.opdClass::$lastQuery.'</i><br/>';
|
||||
}
|
||||
|
||||
class opdClass
|
||||
{
|
||||
static public $lastQuery;
|
||||
public $dsn;
|
||||
public $debugConsole;
|
||||
|
||||
// Debug etc.
|
||||
private $queryMonitor;
|
||||
private $consoleCode;
|
||||
private $i;
|
||||
|
||||
private $counterExecuted = 0;
|
||||
private $counterRequested = 0;
|
||||
private $counterTime = 0;
|
||||
private $counterTimeExecuted = 0;
|
||||
private $transactions = 0;
|
||||
private $transactionsCommit = 0;
|
||||
private $transactionsRollback = 0;
|
||||
|
||||
// PDO
|
||||
private $pdo;
|
||||
|
||||
// Connection
|
||||
private $user;
|
||||
private $password;
|
||||
private $driverOpts;
|
||||
private $connected;
|
||||
|
||||
// Cache
|
||||
private $cacheDir;
|
||||
private $cache;
|
||||
private $cacheId;
|
||||
private $cacheIds = array();
|
||||
|
||||
public function __construct($dsn, $user, $password, $driverOpts = array())
|
||||
{
|
||||
$this -> dsn = $dsn;
|
||||
$this -> user = $user;
|
||||
$this -> password = $password;
|
||||
$this -> driverOpts = $driverOpts;
|
||||
$this -> queryCount = 0;
|
||||
$this -> i = 0;
|
||||
} // end __construct();
|
||||
|
||||
private function makeConnection()
|
||||
{
|
||||
if(is_null($this -> connected))
|
||||
{
|
||||
$this -> connected = true;
|
||||
$this -> pdo = new PDO($this -> dsn, $this -> user, $this -> password, $this -> driverOpts);
|
||||
$this -> pdo -> setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
}
|
||||
} // end makeConnection();
|
||||
|
||||
public function __destruct()
|
||||
{
|
||||
if($this -> debugConsole)
|
||||
{
|
||||
if($this -> transactionsCommit + $this -> transactionsRollback != $this -> transactions)
|
||||
{
|
||||
// If any transaction closed automatically
|
||||
$this -> transactionsCommit = $this -> transactions - $this -> transactionsRollback;
|
||||
}
|
||||
|
||||
$config = array(
|
||||
'Open Power Driver version' => OPD_VERSION,
|
||||
'DSN' => $this -> dsn,
|
||||
'Database connection' => ($this -> connected ? 'Yes' : 'No'),
|
||||
'Requested queries' => $this -> counterRequested,
|
||||
'Executed queries' => $this -> counterExecuted,
|
||||
'Total database time' => $this -> counterTime.' s',
|
||||
'Executed queries time' => $this -> counterTimeExecuted.' s',
|
||||
'Transactions opened' => $this -> transactions,
|
||||
'Commited transactions' => $this -> transactionsCommit,
|
||||
'Rolled back transactions' => $this -> transactionsRollback
|
||||
);
|
||||
|
||||
eval($this->consoleCode);
|
||||
if(isset($debugCode))
|
||||
{
|
||||
echo '<script language="JavaScript">
|
||||
opd_console = window.open("","OPD debug console","width=680,height=350,resizable,scrollbars=yes");
|
||||
'.$debugCode.'</script>';
|
||||
}
|
||||
}
|
||||
} // end __destruct();
|
||||
|
||||
static public function create($config)
|
||||
{
|
||||
if(is_string($config))
|
||||
{
|
||||
$config = parse_ini_file($config);
|
||||
}
|
||||
|
||||
if(!is_array($config))
|
||||
{
|
||||
throw new Exception('Invalid Open Power Driver configuration: no configuration array.');
|
||||
}
|
||||
|
||||
$opd = new opdClass($config['dsn'], $config['user'], $config['password']);
|
||||
if(isset($config['cache']))
|
||||
{
|
||||
$opd -> setCacheDirectory($config['cache']);
|
||||
}
|
||||
if(isset($config['debugConsole']))
|
||||
{
|
||||
$opd -> debugConsole = $config['debugConsole'];
|
||||
}
|
||||
return $opd;
|
||||
} // end create();
|
||||
|
||||
public function beginTransaction()
|
||||
{
|
||||
$this -> transactions++;
|
||||
$this -> makeConnection();
|
||||
return $this -> pdo -> beginTransaction();
|
||||
} // end beginTransaction();
|
||||
|
||||
public function commit()
|
||||
{
|
||||
$this -> transactionsCommit++;
|
||||
$this -> makeConnection();
|
||||
return $this -> pdo -> commit();
|
||||
} // end commit();
|
||||
|
||||
public function errorCode()
|
||||
{
|
||||
$this -> makeConnection();
|
||||
return $this -> pdo -> errorCode();
|
||||
} // end errorCode();
|
||||
|
||||
public function errorInfo()
|
||||
{
|
||||
$this -> makeConnection();
|
||||
return $this -> pdo -> errorInfo();
|
||||
} // end errorInfo();
|
||||
|
||||
public function exec($statement, $id = NULL)
|
||||
{
|
||||
if(!is_null($id))
|
||||
{
|
||||
$stmt = $this -> prepare($statement);
|
||||
$stmt -> bindValue(':id', $id, PDO::PARAM_INT);
|
||||
return $stmt -> execute();
|
||||
}
|
||||
|
||||
$this -> makeConnection();
|
||||
$this -> beginDebugDefinition($statement);
|
||||
$this -> startTimer(false, false);
|
||||
$result = $this -> pdo -> exec($statement);
|
||||
$this -> endTimer();
|
||||
opdClass::$lastQuery = $statement;
|
||||
$this -> endDebugDefinition($result);
|
||||
return $result;
|
||||
} // end exec();
|
||||
|
||||
public function getAttribute($attribute)
|
||||
{
|
||||
$this -> makeConnection();
|
||||
return $this -> pdo -> getAttribute($attribute);
|
||||
} // end getAttribute();
|
||||
|
||||
public function getAvailableDrivers()
|
||||
{
|
||||
$this -> makeConnection();
|
||||
return $this -> pdo -> getAvailableDrivers();
|
||||
} // end getAvailableDrivers();
|
||||
|
||||
public function lastInsertId($sequence = NULL)
|
||||
{
|
||||
$this -> makeConnection();
|
||||
if($sequence == NULL)
|
||||
{
|
||||
return $this -> pdo -> lastInsertId();
|
||||
}
|
||||
return $this -> pdo -> lastInsertId($sequence);
|
||||
} // end lastInsertId();
|
||||
|
||||
public function prepare($statement, $options = array())
|
||||
{
|
||||
if($this -> cache == false)
|
||||
{
|
||||
if(count($options) == 0)
|
||||
{
|
||||
$options = array(PDO::ATTR_CURSOR, PDO::CURSOR_FWDONLY);
|
||||
}
|
||||
$this -> makeConnection();
|
||||
$result = $this -> pdo -> prepare($statement, $options);
|
||||
opdClass::$lastQuery = $statement;
|
||||
return new opdStatement($this, $result, $statement);
|
||||
}
|
||||
else
|
||||
{
|
||||
$cacheTests = array();
|
||||
$needsQuery = 0;
|
||||
$result = NULL;
|
||||
$time = time();
|
||||
if(count($this -> cacheIds) > 0)
|
||||
{
|
||||
foreach($this -> cacheIds as $idx => $id)
|
||||
{
|
||||
if($id == false)
|
||||
{
|
||||
// This instance must not be cached
|
||||
$cacheTests[] = array(
|
||||
'id' => false,
|
||||
'test' => false
|
||||
);
|
||||
$needsQuery = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
// This instance should be cached
|
||||
if(!is_null($this -> cachePeroids[$idx]))
|
||||
{
|
||||
$test = (@filemtime($this->cacheDir.'%%'.$id.'.php') + $this -> cachePeroids[$idx] > $time);
|
||||
}
|
||||
else
|
||||
{
|
||||
$test = file_exists($this->cacheDir.'%%'.$id.'.php');
|
||||
}
|
||||
$cacheTests[] = array(
|
||||
'id' => $id,
|
||||
'test' => $test
|
||||
);
|
||||
if(!$test)
|
||||
{
|
||||
$needsQuery = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if($needsQuery)
|
||||
{
|
||||
if(count($options) == 0)
|
||||
{
|
||||
$options = array(PDO::ATTR_CURSOR, PDO::CURSOR_FWDONLY);
|
||||
}
|
||||
$this -> makeConnection();
|
||||
$result = $this -> pdo -> prepare($statement, $options);
|
||||
opdClass::$lastQuery = $statement;
|
||||
}
|
||||
$this -> cacheIds = array();
|
||||
$this -> cachePeroids = array();
|
||||
$this -> cache = false;
|
||||
return new opdPreparedCacheStatement($this, $cacheTests, $result, $statement);
|
||||
}
|
||||
} // end prepare();
|
||||
|
||||
public function query($statement, $fetchMode = PDO::FETCH_ASSOC)
|
||||
{
|
||||
$this -> beginDebugDefinition($statement);
|
||||
if($this -> cache)
|
||||
{
|
||||
$this -> cache = false;
|
||||
if(!is_null($this -> cachePeroid))
|
||||
{
|
||||
if(@filemtime($this->cacheDir.'%%'.$this->cacheId.'.php') + $this -> cachePeroid > time())
|
||||
{
|
||||
$this -> cachePeroid = NULL;
|
||||
return new opdCachedStatement($this, true, $this->cacheId);
|
||||
}
|
||||
$this -> cachePeroid = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(file_exists($this->cacheDir.'%%'.$this->cacheId.'.php'))
|
||||
{
|
||||
return new opdCachedStatement($this, true, $this->cacheId);
|
||||
}
|
||||
}
|
||||
$this -> makeConnection();
|
||||
$this -> startTimer(true, false);
|
||||
$result = $this -> pdo -> query($statement);
|
||||
$this -> endTimer();
|
||||
opdClass::$lastQuery = $statement;
|
||||
|
||||
$result -> setFetchMode($fetchMode);
|
||||
return new opdCachedStatement($this, false, $result, $this->cacheId);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this -> cache = false;
|
||||
$this -> makeConnection();
|
||||
$this -> startTimer(false, false);
|
||||
$result = $this -> pdo -> query($statement);
|
||||
$this -> endTimer();
|
||||
opdClass::$lastQuery = $statement;
|
||||
|
||||
$result -> setFetchMode($fetchMode);
|
||||
return new opdStatement($this, $result);
|
||||
}
|
||||
} // end query();
|
||||
|
||||
public function quote($string, $parameterType = PDO::PARAM_STR)
|
||||
{
|
||||
$this -> makeConnection();
|
||||
return $this -> pdo -> quote($string, $parameterType);
|
||||
} // end quote();
|
||||
|
||||
public function rollBack()
|
||||
{
|
||||
$this -> transactionsRollback++;
|
||||
$this -> makeConnection();
|
||||
return $this -> pdo -> rollBack();
|
||||
} // end rollBack();
|
||||
|
||||
public function setAttribute($name, $value)
|
||||
{
|
||||
$this -> makeConnection();
|
||||
return $this -> pdo -> setAttribute($name, $value);
|
||||
} // end setAttribute();
|
||||
|
||||
// --------------------
|
||||
// OPD-specific methods
|
||||
// --------------------
|
||||
|
||||
public function get($query)
|
||||
{
|
||||
$stmt = $this -> query($query, PDO::FETCH_NUM);
|
||||
if($row = $stmt -> fetch())
|
||||
{
|
||||
$stmt -> closeCursor();
|
||||
return $row[0];
|
||||
}
|
||||
$stmt -> closeCursor();
|
||||
return NULL;
|
||||
} // end get();
|
||||
|
||||
public function getId($query, $id)
|
||||
{
|
||||
$stmt = $this -> prepare($query);
|
||||
$stmt -> bindValue(':id', $id, PDO::PARAM_INT);
|
||||
$stmt -> execute();
|
||||
if($row = $stmt -> fetch(PDO::FETCH_NUM))
|
||||
{
|
||||
$stmt -> closeCursor();
|
||||
return $row[0];
|
||||
}
|
||||
$stmt -> closeCursor();
|
||||
return NULL;
|
||||
} // end getId();
|
||||
|
||||
public function setCacheDirectory($dir)
|
||||
{
|
||||
$this -> cacheDir = $dir;
|
||||
} // end setCacheDirectory();
|
||||
|
||||
public function getCacheDirectory()
|
||||
{
|
||||
return $this -> cacheDir;
|
||||
} // end getCacheDirectory();
|
||||
|
||||
public function setCache($id, $prepare = false)
|
||||
{
|
||||
$this -> cache = true;
|
||||
$this -> cacheId = $id;
|
||||
$this -> cachePeroid = NULL;
|
||||
if($prepare == true)
|
||||
{
|
||||
$this -> cacheIds[] = $id;
|
||||
$this -> cachePeroids[] = NULL;
|
||||
}
|
||||
} // end setCache();
|
||||
|
||||
public function setCacheExpire($peroid, $id, $prepare = false)
|
||||
{
|
||||
$this -> cache = true;
|
||||
$this -> cacheId = $id;
|
||||
$this -> cachePeroid = $peroid;
|
||||
if($prepare == true)
|
||||
{
|
||||
$this -> cacheIds[] = $id;
|
||||
$this -> cachePeroids[] = $peroid;
|
||||
}
|
||||
} // end setCacheExpire();
|
||||
|
||||
public function clearCache($name)
|
||||
{
|
||||
if(file_exists($this -> cacheDir.'%%'.$name.'.php'))
|
||||
{
|
||||
unlink($this -> cacheDir.'%%'.$name.'.php');
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} // end clearCache();
|
||||
|
||||
public function clearCacheGroup($name)
|
||||
{
|
||||
$list = glob($this -> cacheDir.'%%'.$name.'.php', GLOB_BRACE);
|
||||
if(is_array($list))
|
||||
{
|
||||
foreach($list as $file)
|
||||
{
|
||||
unlink($file);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} // end clearCacheGroup();
|
||||
|
||||
public function getCounter()
|
||||
{
|
||||
return $this -> counterExecuted;
|
||||
} // end getCounter();
|
||||
|
||||
// --------------------
|
||||
// Debug console methods
|
||||
// --------------------
|
||||
|
||||
public function beginDebugDefinition($query)
|
||||
{
|
||||
if($this -> debugConsole)
|
||||
{
|
||||
if(is_null($this -> consoleCode))
|
||||
{
|
||||
$this -> consoleCode = file_get_contents(OPD_DIR.'opd.debug.php');
|
||||
}
|
||||
|
||||
$this -> queryMonitor[$this->i] = array(
|
||||
'query' => $query,
|
||||
'result' => '',
|
||||
'cache' => 0,
|
||||
'cached' => 0,
|
||||
'execution' => 0
|
||||
);
|
||||
}
|
||||
} // end beginDebugDefinition();
|
||||
|
||||
public function startTimer($cacheEnabled, $cached)
|
||||
{
|
||||
$this -> counterRequested++;
|
||||
if(!$cached)
|
||||
{
|
||||
$this -> counterExecuted++;
|
||||
}
|
||||
$this -> queryMonitor[$this->i]['cache'] = $cacheEnabled == true ? 'Yes' : 'No';
|
||||
$this -> queryMonitor[$this->i]['cached'] = $cached;
|
||||
if($this -> debugConsole)
|
||||
{
|
||||
$this -> time = microtime(true);
|
||||
}
|
||||
} // end startTimer();
|
||||
|
||||
public function endTimer()
|
||||
{
|
||||
if($this -> debugConsole)
|
||||
{
|
||||
$this -> queryMonitor[$this->i]['execution'] = round(microtime(true) - $this -> time, 6);
|
||||
$this -> counterTime += $this -> queryMonitor[$this->i]['execution'];
|
||||
if(!$this -> queryMonitor[$this->i]['cached'])
|
||||
{
|
||||
$this -> counterTimeExecuted += $this -> queryMonitor[$this->i]['execution'];
|
||||
}
|
||||
}
|
||||
} // end endTimer();
|
||||
|
||||
public function endDebugDefinition($result)
|
||||
{
|
||||
if($this -> debugConsole)
|
||||
{
|
||||
$this -> queryMonitor[$this -> i]['result'] = $result;
|
||||
$this -> i++;
|
||||
}
|
||||
} // end endDebugDefinition();
|
||||
}
|
||||
|
||||
?>
|
||||
118
autoload/opd.debug.php
Normal file
118
autoload/opd.debug.php
Normal file
@@ -0,0 +1,118 @@
|
||||
$debugCode = 'opd_console.document.write(\'<html>\');
|
||||
opd_console.document.write(\'<head>\');
|
||||
opd_console.document.write(\'<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />\');
|
||||
opd_console.document.write(\'<title>OPD Debug Console</title>\');
|
||||
opd_console.document.write(\'<style>\');
|
||||
opd_console.document.write(\'body{\');
|
||||
opd_console.document.write(\' background: #ffffff;\');
|
||||
opd_console.document.write(\' font-family: Verdana, Arial, Tahoma, Helvetica;\');
|
||||
opd_console.document.write(\' font-size: 11px;\');
|
||||
opd_console.document.write(\'}\');
|
||||
opd_console.document.write(\'table#info{\');
|
||||
opd_console.document.write(\' width: 100%;\');
|
||||
opd_console.document.write(\' padding: 0;\');
|
||||
opd_console.document.write(\' margin: 0;\');
|
||||
opd_console.document.write(\' border-spacing: 0;\');
|
||||
opd_console.document.write(\' border: 1px #333333 solid;\');
|
||||
opd_console.document.write(\'}\');
|
||||
opd_console.document.write(\'table#info td.field{\');
|
||||
opd_console.document.write(\' margin: 0;\');
|
||||
opd_console.document.write(\' width: 30%;\');
|
||||
opd_console.document.write(\' color: #474747;\');
|
||||
opd_console.document.write(\' border-width: 1px 0 1px 0;\');
|
||||
opd_console.document.write(\' border-style: solid;\');
|
||||
opd_console.document.write(\' border-color: #ffffff #ffffff #b2b2b2 #ffffff;\');
|
||||
opd_console.document.write(\' background-color: #dadada;\');
|
||||
opd_console.document.write(\' font-size: 11px;\');
|
||||
opd_console.document.write(\'}\');
|
||||
opd_console.document.write(\'table#info td.value{\');
|
||||
opd_console.document.write(\' margin: 0;\');
|
||||
opd_console.document.write(\' width: 70%;\');
|
||||
opd_console.document.write(\' border-width: 1px;\');
|
||||
opd_console.document.write(\' border-color: #ffffff #e4e4e4 #e4e4e4 #ffffff;\');
|
||||
opd_console.document.write(\' border-style: solid;\');
|
||||
opd_console.document.write(\' background-color: #efefef;\');
|
||||
opd_console.document.write(\' font-size: 11px;\');
|
||||
opd_console.document.write(\'}\');
|
||||
opd_console.document.write(\'table#queries{\');
|
||||
opd_console.document.write(\' width: 100%;\');
|
||||
opd_console.document.write(\' padding: 0;\');
|
||||
opd_console.document.write(\' margin: 0;\');
|
||||
opd_console.document.write(\' margin-top: 4px;\');
|
||||
opd_console.document.write(\' border-spacing: 0;\');
|
||||
opd_console.document.write(\' border: 1px #333333 solid;\');
|
||||
opd_console.document.write(\'}\');
|
||||
opd_console.document.write(\'table#queries thead td{\');
|
||||
opd_console.document.write(\' text-align: left;\');
|
||||
opd_console.document.write(\' padding: 3px 3px 3px 12px;\');
|
||||
opd_console.document.write(\' font-size: 12px;\');
|
||||
opd_console.document.write(\' color: #474747;\');
|
||||
opd_console.document.write(\' border-width: 1px 0 1px 0;\');
|
||||
opd_console.document.write(\' border-style: solid;\');
|
||||
opd_console.document.write(\' border-color: #ffffff #ffffff #b2b2b2 #ffffff;\');
|
||||
opd_console.document.write(\' background-color: #dadada;\');
|
||||
opd_console.document.write(\' font-weight: bold;\');
|
||||
opd_console.document.write(\'}\');
|
||||
opd_console.document.write(\'table#queries tbody td{\');
|
||||
opd_console.document.write(\' background-color: #f5f5f5;\');
|
||||
opd_console.document.write(\' border-width: 0 1px 1px 0;\');
|
||||
opd_console.document.write(\' border-style: solid;\');
|
||||
opd_console.document.write(\' border-bottom-color: #d2d2d2;\');
|
||||
opd_console.document.write(\' border-right-color: #d2d2d2;\');
|
||||
opd_console.document.write(\' font-size: 10px;\');
|
||||
opd_console.document.write(\' margin-top: 3px;\');
|
||||
opd_console.document.write(\'}\');
|
||||
opd_console.document.write(\'table#queries tbody tr.cached td{\');
|
||||
opd_console.document.write(\' background: #ededff;\');
|
||||
opd_console.document.write(\'}\');
|
||||
opd_console.document.write(\'</style>\');
|
||||
opd_console.document.write(\'</head>\');
|
||||
opd_console.document.write(\'<body>\');
|
||||
opd_console.document.write(\'<h1>OPD Debug Console</h1>\');
|
||||
opd_console.document.write(\'<table id="info">\');
|
||||
';
|
||||
|
||||
foreach($config as $name => $value)
|
||||
{
|
||||
$debugCode .= 'opd_console.document.write(\'<tr>\');
|
||||
opd_console.document.write(\'<td class="field">'.$name.'</td>\');
|
||||
opd_console.document.write(\'<td class="value">'.$value.'</td>\');
|
||||
opd_console.document.write(\'</tr>\');';
|
||||
}
|
||||
|
||||
$debugCode .= '
|
||||
opd_console.document.write(\'</table>\');
|
||||
opd_console.document.write(\'<table id="queries">\');
|
||||
opd_console.document.write(\'<thead>\');
|
||||
opd_console.document.write(\'<tr>\');
|
||||
opd_console.document.write(\' <td>Query</td>\');
|
||||
opd_console.document.write(\' <td>Cache</td>\');
|
||||
opd_console.document.write(\' <td>Result</td>\');
|
||||
opd_console.document.write(\' <td>Execution time</td>\');
|
||||
opd_console.document.write(\'</tr>\');
|
||||
opd_console.document.write(\'</thead>\');
|
||||
opd_console.document.write(\'<tbody>\');
|
||||
';
|
||||
|
||||
foreach($this -> queryMonitor as $data)
|
||||
{
|
||||
if($data['cached'] == true)
|
||||
{
|
||||
$debugCode .= 'opd_console.document.write(\'<tr class="cached">\');';
|
||||
}
|
||||
else
|
||||
{
|
||||
$debugCode .= 'opd_console.document.write(\'<tr>\');';
|
||||
}
|
||||
$debugCode .= 'opd_console.document.write(\' <td>'.addslashes($data['query']).'</td>\');
|
||||
opd_console.document.write(\' <td>'.$data['cache'].'</td>\');
|
||||
opd_console.document.write(\' <td>'.$data['result'].'</td>\');
|
||||
opd_console.document.write(\' <td>'.$data['execution'].' s</td>\');
|
||||
opd_console.document.write(\'</tr>\');';
|
||||
}
|
||||
$debugCode .= '
|
||||
opd_console.document.write(\'</tbody>\');
|
||||
opd_console.document.write(\'</table>\');
|
||||
opd_console.document.write(\'\');
|
||||
opd_console.document.write(\'</body>\');
|
||||
opd_console.document.write(\'</html>\');';
|
||||
629
autoload/opd.statement.php
Normal file
629
autoload/opd.statement.php
Normal file
@@ -0,0 +1,629 @@
|
||||
<?php
|
||||
// -------------------------------------------------------------------- //
|
||||
// Open Power Board //
|
||||
// Open Power Driver //
|
||||
// Copyright (c) 2005 OpenPB team, http://www.openpb.net/ //
|
||||
// -------------------------------------------------------------------- //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU Lesser General Public License as //
|
||||
// published by the Free Software Foundation; either version 2.1 of the //
|
||||
// License, or (at your option) any later version. //
|
||||
// -------------------------------------------------------------------- //
|
||||
//
|
||||
// $Id: opd.statement.php 49 2006-04-22 06:46:19Z zyxist $
|
||||
|
||||
interface iopdStatement
|
||||
{
|
||||
public function bindColumn($column, &$param, $type = NULL);
|
||||
public function bindParam($parameter, &$variable, $dataType = NULL, $length = NULL, $driverOptions = NULL);
|
||||
public function bindValue($parameter, $value, $dataType = NULL);
|
||||
public function closeCursor();
|
||||
public function columnCount();
|
||||
public function errorCode();
|
||||
public function errorInfo();
|
||||
public function execute($inputParameters = array());
|
||||
public function fetch($fetchStyle = PDO::FETCH_BOTH, $orientation = PDO::FETCH_ORI_NEXT, $offset = NULL);
|
||||
public function fetchAll($fetchStyle = PDO::FETCH_BOTH, $columnIndex = 0);
|
||||
public function fetchColumn($columnNumber = 0);
|
||||
public function getAttribute($attribute);
|
||||
public function getColumnMeta($column);
|
||||
public function nextRowset();
|
||||
public function rowCount();
|
||||
public function setAttribute($attribute, $value);
|
||||
public function setFetchMode($mode, $className = NULL);
|
||||
}
|
||||
|
||||
class opdStatement implements iopdStatement, Iterator
|
||||
{
|
||||
private $stmt;
|
||||
private $opd;
|
||||
private $items;
|
||||
private $query;
|
||||
|
||||
private $buffer;
|
||||
private $i;
|
||||
|
||||
public function __construct(opdClass $opd, PDOStatement $stmt, $query = NULL)
|
||||
{
|
||||
$this -> stmt = $stmt;
|
||||
$this -> opd = $opd;
|
||||
$this -> query = $query;
|
||||
} // end __construct();
|
||||
|
||||
public function bindColumn($column, &$param, $type = NULL)
|
||||
{
|
||||
if($type == NULL)
|
||||
{
|
||||
return $this -> stmt -> bindColumn($column, $param);
|
||||
}
|
||||
return $this -> stmt -> bindColumn($column, $param, $type);
|
||||
} // end bindColumn();
|
||||
|
||||
public function bindParam($parameter, &$variable, $dataType = NULL, $length = NULL, $driverOptions = NULL)
|
||||
{
|
||||
if($dataType == NULL)
|
||||
{
|
||||
return $this -> stmt -> bindParam($parameter, $variable);
|
||||
}
|
||||
elseif($length == NULL)
|
||||
{
|
||||
return $this -> stmt -> bindParam($parameter, $variable, $dataType);
|
||||
}
|
||||
elseif($driverOptions == NULL)
|
||||
{
|
||||
return $this -> stmt -> bindParam($parameter, $variable, $dataType, $length);
|
||||
}
|
||||
return $this -> stmt -> bindParam($parameter, $variable, $dataType, $length, $driverOptions);
|
||||
} // end bindParam();
|
||||
|
||||
public function bindValue($parameter, $value, $dataType = NULL)
|
||||
{
|
||||
if($dataType == NULL)
|
||||
{
|
||||
return $this -> stmt -> bindValue($parameter, $value);
|
||||
}
|
||||
return $this -> stmt -> bindValue($parameter, $value, $dataType);
|
||||
} // end bindValue();
|
||||
|
||||
public function closeCursor()
|
||||
{
|
||||
$this -> opd -> endDebugDefinition($this -> items);
|
||||
return $this -> stmt -> closeCursor();
|
||||
} // end closeCursor();
|
||||
|
||||
public function columnCount()
|
||||
{
|
||||
return $this -> stmt -> columnCount();
|
||||
} // end columnCount();
|
||||
|
||||
public function errorCode()
|
||||
{
|
||||
return $this -> stmt -> errorCode();
|
||||
} // end errorCode();
|
||||
|
||||
public function errorInfo()
|
||||
{
|
||||
return $this -> stmt -> errorInfo();
|
||||
} // end errorInfo();
|
||||
|
||||
public function execute($inputParameters = NULL)
|
||||
{
|
||||
if($inputParameters == NULL)
|
||||
{
|
||||
$this -> opd -> beginDebugDefinition($this -> query);
|
||||
$this -> opd -> startTimer(false, false);
|
||||
$result = $this -> stmt -> execute();
|
||||
$this -> opd -> endTimer();
|
||||
}
|
||||
else
|
||||
{
|
||||
$this -> opd -> beginDebugDefinition($this -> query);
|
||||
$this -> opd -> startTimer(false, false);
|
||||
$result = $this -> stmt -> execute($inputParameters);
|
||||
$this -> opd -> endTimer();
|
||||
}
|
||||
$this -> items = 0;
|
||||
$letter = strtolower($this->query[0]);
|
||||
if($letter == 'i' || $letter == 'u' || $letter == 'd' || $letter == 'r')
|
||||
{
|
||||
$this -> items = $this -> stmt -> rowCount();
|
||||
$this -> opd -> endDebugDefinition($this -> items);
|
||||
}
|
||||
|
||||
return $result;
|
||||
} // end execute();
|
||||
|
||||
public function fetch($fetchStyle = PDO::FETCH_BOTH, $orientation = PDO::FETCH_ORI_NEXT, $offset = NULL)
|
||||
{
|
||||
if($offset == NULL)
|
||||
{
|
||||
if($data = $this -> stmt -> fetch($fetchStyle, $orientation))
|
||||
{
|
||||
$this -> items++;
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
if($data = $this -> stmt -> fetch($fetchStyle, $orientation, $offset))
|
||||
{
|
||||
$this -> items++;
|
||||
return $data;
|
||||
}
|
||||
} // end fetch();
|
||||
|
||||
public function fetchAll($fetchStyle = PDO::FETCH_BOTH, $columnIndex = 0)
|
||||
{
|
||||
if($fetchStyle == PDO::FETCH_COLUMN)
|
||||
{
|
||||
$data = $this -> stmt -> fetchAll($fetchStyle, $columnIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
$data = $this -> stmt -> fetchAll($fetchStyle);
|
||||
}
|
||||
$this -> items = count($data);
|
||||
return $data;
|
||||
} // end fetchAll();
|
||||
|
||||
public function fetchColumn($columnNumber = 0)
|
||||
{
|
||||
$this -> items++;
|
||||
return $this -> stmt -> fetchColumn($columnNumber);
|
||||
} // end fetchColumn();
|
||||
|
||||
public function getAttribute($attribute)
|
||||
{
|
||||
return $this -> stmt -> getAttribute($attribute);
|
||||
} // end getAttribute();
|
||||
|
||||
public function getColumnMeta($column)
|
||||
{
|
||||
return $this -> stmt -> getColumnMeta($column);
|
||||
} // end getColumnMeta();
|
||||
|
||||
public function nextRowset()
|
||||
{
|
||||
$this -> items++;
|
||||
return $this -> stmt -> nextRowset();
|
||||
} // end nextRowset();
|
||||
|
||||
public function rowCount()
|
||||
{
|
||||
return $this -> stmt -> rowCount();
|
||||
} // end rowCount();
|
||||
|
||||
public function setAttribute($attribute, $value)
|
||||
{
|
||||
return $this -> stmt -> setAttribute($attribute, $value);
|
||||
} // end setAttribute();
|
||||
|
||||
public function setFetchMode($mode, $className = NULL, $args = array())
|
||||
{
|
||||
if($mode == PDO::FETCH_CLASS)
|
||||
{
|
||||
return $this -> stmt -> setFetchMode($mode, $className, $args);
|
||||
}
|
||||
return $this -> stmt -> setFetchMode($mode);
|
||||
} // end setFetchMode();
|
||||
|
||||
public function rowNumber()
|
||||
{
|
||||
return $this -> items;
|
||||
} // end rowNumber();
|
||||
|
||||
/*
|
||||
* ITERATOR INTERFACE IMPLEMENTATION
|
||||
*/
|
||||
|
||||
public function current()
|
||||
{
|
||||
return $this -> buffer;
|
||||
} // end current();
|
||||
|
||||
public function key()
|
||||
{
|
||||
return $this -> i;
|
||||
} // end key();
|
||||
|
||||
public function valid()
|
||||
{
|
||||
if($this -> buffer = $this -> stmt -> fetch())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
$this -> items = $this -> i - 1;
|
||||
$this -> stmt -> closeCursor();
|
||||
return false;
|
||||
} // end valid();
|
||||
|
||||
public function next()
|
||||
{
|
||||
$this -> i++;
|
||||
} // end next();
|
||||
|
||||
public function rewind()
|
||||
{
|
||||
$this -> buffer = array();
|
||||
$this -> i = 0;
|
||||
} // end rewind();
|
||||
}
|
||||
|
||||
class opdCachedStatement implements iopdStatement, Iterator
|
||||
{
|
||||
protected $stmt;
|
||||
protected $opd;
|
||||
|
||||
protected $cache;
|
||||
protected $cacheId;
|
||||
protected $cacheDir;
|
||||
protected $data;
|
||||
protected $i;
|
||||
|
||||
public function __construct(opdClass $opd, $cacheStatus, $param2 = NULL, $param3 = NULL)
|
||||
{
|
||||
$this -> opd = $opd;
|
||||
$this -> cache = $cacheStatus;
|
||||
$this -> cacheDir = $this -> opd -> getCacheDirectory();
|
||||
if($this -> cache)
|
||||
{
|
||||
$this -> cacheId = $param2;
|
||||
if($this -> cacheId != NULL)
|
||||
{
|
||||
$this -> opd -> startTimer(true, true);
|
||||
$this -> data = unserialize(file_get_contents($this->cacheDir.'%%'.$this->cacheId.'.php'));
|
||||
$this -> opd -> endTimer();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this -> cacheId = $param3;
|
||||
$this -> stmt = $param2;
|
||||
}
|
||||
// set the cursor at the starting position
|
||||
$this -> i = 0;
|
||||
} // end __construct();
|
||||
|
||||
public function bindColumn($column, &$param, $type = NULL)
|
||||
{
|
||||
return false;
|
||||
} // end bindColumn();
|
||||
|
||||
public function bindParam($parameter, &$variable, $dataType = NULL, $length = NULL, $driverOptions = NULL)
|
||||
{
|
||||
return false;
|
||||
} // end bindParam();
|
||||
|
||||
public function bindValue($parameter, $value, $dataType = NULL)
|
||||
{
|
||||
return false;
|
||||
} // end bindValue();
|
||||
|
||||
public function closeCursor()
|
||||
{
|
||||
$this -> opd -> endDebugDefinition(count($this -> data));
|
||||
if(!$this -> cache)
|
||||
{
|
||||
file_put_contents($this->cacheDir.'%%'.$this->cacheId.'.php', serialize($this->data));
|
||||
return $this -> stmt -> closeCursor();
|
||||
}
|
||||
return 1;
|
||||
} // end closeCursor();
|
||||
|
||||
public function columnCount()
|
||||
{
|
||||
return $this -> stmt -> columnCount();
|
||||
} // end columnCount();
|
||||
|
||||
public function errorCode()
|
||||
{
|
||||
return $this -> stmt -> errorCode();
|
||||
} // end errorCode();
|
||||
|
||||
public function errorInfo()
|
||||
{
|
||||
return $this -> stmt -> errorInfo();
|
||||
} // end errorInfo();
|
||||
|
||||
public function execute($inputParameters = NULL)
|
||||
{
|
||||
return false;
|
||||
} // end execute();
|
||||
|
||||
public function fetch($fetchStyle = PDO::FETCH_ASSOC, $orientation = PDO::FETCH_ORI_NEXT, $offset = NULL)
|
||||
{
|
||||
if(!$this -> cache)
|
||||
{
|
||||
if($offset == NULL)
|
||||
{
|
||||
if($data = $this -> stmt -> fetch($fetchStyle, $orientation))
|
||||
{
|
||||
$this -> data[$this->i] = $data;
|
||||
$this -> i++;
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if($data = $this -> stmt -> fetch($fetchStyle, $orientation, $offset))
|
||||
{
|
||||
$this -> data[$this->i] = $data;
|
||||
$this -> i++;
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(isset($this->data[$this->i]))
|
||||
{
|
||||
return $this->data[$this->i++];
|
||||
}
|
||||
}
|
||||
} // end fetch();
|
||||
|
||||
public function fetchAll($fetchStyle = PDO::FETCH_BOTH, $columnIndex = 0)
|
||||
{
|
||||
if(!$this -> cache)
|
||||
{
|
||||
if($fetchStyle == PDO::FETCH_COLUMN)
|
||||
{
|
||||
return $this -> data = $this -> stmt -> fetchAll($fetchStyle, $columnIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this -> data = $this -> stmt -> fetchAll($fetchStyle);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this -> data;
|
||||
}
|
||||
} // end fetchAll();
|
||||
|
||||
public function fetchColumn($columnNumber = 1)
|
||||
{
|
||||
if(!$this -> cache)
|
||||
{
|
||||
return $this -> data[$this->i++] = $this -> stmt -> fetchColumn($columnNumber);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this -> data[$this->i++];
|
||||
}
|
||||
} // end fetchColumn();
|
||||
|
||||
public function getAttribute($attribute)
|
||||
{
|
||||
return $this -> stmt -> getAttribute($attribute);
|
||||
} // end getAttribute();
|
||||
|
||||
public function getColumnMeta($column)
|
||||
{
|
||||
return $this -> stmt -> getColumnMeta($column);
|
||||
} // end getColumnMeta();
|
||||
|
||||
public function nextRowset()
|
||||
{
|
||||
return $this -> stmt -> nextRowset();
|
||||
} // end nextRowset();
|
||||
|
||||
public function rowCount()
|
||||
{
|
||||
return $this -> stmt -> rowCount();
|
||||
} // end rowCount();
|
||||
|
||||
public function setAttribute($attribute, $value)
|
||||
{
|
||||
return $this -> stmt -> setAttribute($attribute, $value);
|
||||
} // end setAttribute();
|
||||
|
||||
public function setFetchMode($mode, $className = NULL)
|
||||
{
|
||||
if($this -> cache)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if($mode == PDO::FETCH_CLASS)
|
||||
{
|
||||
return $this -> stmt -> setFetchMode($mode, $className);
|
||||
}
|
||||
return $this -> stmt -> setFetchMode($mode);
|
||||
} // end setFetchMode();
|
||||
|
||||
public function setCache($id)
|
||||
{
|
||||
$this -> cacheId = $id;
|
||||
} // end setCache();
|
||||
|
||||
/*
|
||||
* ITERATOR INTERFACE IMPLEMENTATION
|
||||
*/
|
||||
|
||||
public function current()
|
||||
{
|
||||
return $this -> data[$this->i-1];
|
||||
} // end current();
|
||||
|
||||
public function key()
|
||||
{
|
||||
return $this -> i - 1;
|
||||
} // end key();
|
||||
|
||||
public function valid()
|
||||
{
|
||||
if($this -> fetch())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
$this -> closeCursor();
|
||||
return false;
|
||||
} // end valid();
|
||||
|
||||
public function next()
|
||||
{
|
||||
} // end next();
|
||||
|
||||
public function rewind()
|
||||
{
|
||||
} // end rewind();
|
||||
}
|
||||
|
||||
class opdPreparedCacheStatement extends opdCachedStatement
|
||||
{
|
||||
private $j;
|
||||
private $cacheIds;
|
||||
|
||||
public function __construct(opdClass $opd, Array $itemList, $stmt, $query)
|
||||
{
|
||||
$this -> query = $query;
|
||||
$this -> opd = $opd;
|
||||
$this -> cacheDir = $this -> opd -> getCacheDirectory();
|
||||
$this -> cacheIds = $itemList;
|
||||
$this -> stmt = $stmt;
|
||||
// set the cursor at the starting position
|
||||
$this -> i = 0;
|
||||
$this -> j = 0;
|
||||
|
||||
$this -> cache = $this -> cacheIds[$this->j]['test'];
|
||||
} // end __construct();
|
||||
|
||||
public function execute($inputParameters = NULL)
|
||||
{
|
||||
if(!isset($this -> cacheIds[$this->j]['test']))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
$this -> opd -> beginDebugDefinition($this -> query);
|
||||
$this -> i = 0;
|
||||
if($this -> cacheIds[$this->j]['test'] == true)
|
||||
{
|
||||
$this -> cache = true;
|
||||
$this -> cacheId = $this -> cacheIds[$this->j]['id'];
|
||||
$this -> opd -> startTimer(true, true);
|
||||
$this -> data = unserialize(file_get_contents($this->cacheDir.'%%'.$this->cacheId.'.php'));
|
||||
$this -> opd -> endTimer();
|
||||
}
|
||||
else
|
||||
{
|
||||
$this -> cache = false;
|
||||
$this -> cacheId = $this -> cacheIds[$this->j]['id'];
|
||||
$this -> data = array();
|
||||
|
||||
if($inputParameters == NULL)
|
||||
{
|
||||
$this -> opd -> startTimer(true, false);
|
||||
$result = $this -> stmt -> execute();
|
||||
$this -> opd -> endTimer();
|
||||
}
|
||||
else
|
||||
{
|
||||
$this -> opd -> startTimer(true, false);
|
||||
$result = $this -> stmt -> execute($inputParameters);
|
||||
$this -> opd -> endTimer();
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
} // end execute();
|
||||
|
||||
public function bindColumn($column, &$param, $type = NULL)
|
||||
{
|
||||
if(!$this -> cache)
|
||||
{
|
||||
if($type == NULL)
|
||||
{
|
||||
return $this -> stmt -> bindColumn($column, $param);
|
||||
}
|
||||
return $this -> stmt -> bindColumn($column, $param, $type);
|
||||
}
|
||||
return true;
|
||||
} // end bindColumn();
|
||||
|
||||
public function bindParam($parameter, &$variable, $dataType = NULL, $length = NULL, $driverOptions = NULL)
|
||||
{
|
||||
if(!$this -> cache)
|
||||
{
|
||||
if($dataType == NULL)
|
||||
{
|
||||
return $this -> stmt -> bindParam($parameter, $variable);
|
||||
}
|
||||
elseif($length == NULL)
|
||||
{
|
||||
return $this -> stmt -> bindParam($parameter, $variable, $dataType);
|
||||
}
|
||||
elseif($driverOptions == NULL)
|
||||
{
|
||||
return $this -> stmt -> bindParam($parameter, $variable, $dataType, $length);
|
||||
}
|
||||
return $this -> stmt -> bindParam($parameter, $variable, $dataType, $length, $driverOptions);
|
||||
}
|
||||
return true;
|
||||
} // end bindParam();
|
||||
|
||||
public function bindValue($parameter, $value, $dataType = NULL)
|
||||
{
|
||||
if(!$this -> cache)
|
||||
{
|
||||
if($dataType == NULL)
|
||||
{
|
||||
return $this -> stmt -> bindValue($parameter, $value);
|
||||
}
|
||||
return $this -> stmt -> bindValue($parameter, $value, $dataType);
|
||||
}
|
||||
return true;
|
||||
} // end bindValue();
|
||||
|
||||
public function closeCursor()
|
||||
{
|
||||
if($this -> cacheId == false)
|
||||
{
|
||||
$this -> opd -> endDebugDefinition($this -> i);
|
||||
return $this -> stmt -> closeCursor();
|
||||
}
|
||||
$result = parent::closeCursor();
|
||||
$this -> j++;
|
||||
if(isset($this -> cacheIds[$this->j]))
|
||||
{
|
||||
$this -> cache = $this -> cacheIds[$this->j]['test'];
|
||||
}
|
||||
return $result;
|
||||
} // end closeCursor();
|
||||
|
||||
public function fetch($fetchStyle = PDO::FETCH_ASSOC, $orientation = PDO::FETCH_ORI_NEXT, $offset = NULL)
|
||||
{
|
||||
if($this -> cacheId == false)
|
||||
{
|
||||
return $this -> stmt -> fetch($fetchStyle, $orientation, $offset);
|
||||
}
|
||||
return parent::fetch($fetchStyle, $orientation, $offset);
|
||||
} // end fetch();
|
||||
|
||||
public function fetchAll($fetchStyle = PDO::FETCH_BOTH, $columnIndex = 0)
|
||||
{
|
||||
if($fetchStyle == PDO::FETCH_COLUMN)
|
||||
{
|
||||
if($this -> cacheId == false)
|
||||
{
|
||||
return $this -> stmt -> fetch($fetchStyle, $columnIndex);
|
||||
}
|
||||
return parent::fetchAll($fetchStyle, $columnIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
if($this -> cacheId == false)
|
||||
{
|
||||
return $this -> stmt -> fetch($fetchStyle);
|
||||
}
|
||||
return parent::fetchAll($fetchStyle);
|
||||
}
|
||||
} // end fetchAll();
|
||||
|
||||
public function fetchColumn($columnNumber = 1)
|
||||
{
|
||||
if($this -> cacheId == false)
|
||||
{
|
||||
return $this -> stmt -> fetch($columnNumber);
|
||||
}
|
||||
return parent::fetchColumn($columnNumber);
|
||||
} // end fetchColumn();
|
||||
}
|
||||
|
||||
?>
|
||||
125
autoload/savant3/Error.php
Normal file
125
autoload/savant3/Error.php
Normal file
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Provides a simple error class for Savant.
|
||||
*
|
||||
* @package Savant3
|
||||
*
|
||||
* @author Paul M. Jones <pmjones@ciaweb.net>
|
||||
*
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
||||
*
|
||||
* @version $Id: Error.php,v 1.5 2005/05/27 14:03:50 pmjones Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* Provides a simple error class for Savant.
|
||||
*
|
||||
* @package Savant3
|
||||
*
|
||||
* @author Paul M. Jones <pmjones@ciaweb.net>
|
||||
*
|
||||
*/
|
||||
|
||||
class Savant3_Error {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* The error code, typically a Savant 'ERR_*' string.
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
*/
|
||||
|
||||
public $code = null;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* An array of error-specific information.
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
* @var array
|
||||
*
|
||||
*/
|
||||
|
||||
public $info = array();
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* The error severity level.
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
* @var int
|
||||
*
|
||||
*/
|
||||
|
||||
public $level = E_USER_ERROR;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* A debug backtrace for the error, if any.
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
* @var array
|
||||
*
|
||||
*/
|
||||
|
||||
public $trace = null;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Constructor.
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
* @param array $conf An associative array where the key is a
|
||||
* Savant3_Error property and the value is the value for that
|
||||
* property.
|
||||
*
|
||||
*/
|
||||
|
||||
public function __construct($conf = array())
|
||||
{
|
||||
// set public properties
|
||||
foreach ($conf as $key => $val) {
|
||||
$this->$key = $val;
|
||||
}
|
||||
|
||||
// add a backtrace
|
||||
if ($conf['trace'] === true) {
|
||||
$this->trace = debug_backtrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Magic method for output dump.
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
ob_start();
|
||||
echo get_class($this) . ': ';
|
||||
print_r(get_object_vars($this));
|
||||
return ob_get_clean();
|
||||
}
|
||||
}
|
||||
?>
|
||||
29
autoload/savant3/Exception.php
Normal file
29
autoload/savant3/Exception.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* Throws PHP5 exceptions for Savant.
|
||||
*
|
||||
* @package Savant3
|
||||
*
|
||||
* @author Paul M. Jones <pmjones@ciaweb.net>
|
||||
*
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
||||
*
|
||||
* @version $Id: Exception.php,v 1.1 2005/05/27 14:04:36 pmjones Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* A simple Savant3_Exception class.
|
||||
*
|
||||
* @package Savant3
|
||||
*
|
||||
* @author Paul M. Jones <pmjones@ciaweb.net>
|
||||
*
|
||||
*/
|
||||
|
||||
class Savant3_Exception extends Exception {
|
||||
}
|
||||
?>
|
||||
85
autoload/savant3/Filter.php
Normal file
85
autoload/savant3/Filter.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Abstract Savant3_Filter class.
|
||||
*
|
||||
* @package Savant3
|
||||
*
|
||||
* @author Paul M. Jones <pmjones@ciaweb.net>
|
||||
*
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
||||
*
|
||||
* @version $Id: Filter.php,v 1.5 2005/04/29 16:23:50 pmjones Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* Abstract Savant3_Filter class.
|
||||
*
|
||||
* You have to extend this class for it to be useful; e.g., "class
|
||||
* Savant3_Filter_example extends Savant3_Filter".
|
||||
*
|
||||
* @package Savant3
|
||||
*
|
||||
* @author Paul M. Jones <pmjones@ciaweb.net>
|
||||
*
|
||||
*/
|
||||
|
||||
abstract class Savant3_Filter {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Optional reference to the calling Savant object.
|
||||
*
|
||||
* @access protected
|
||||
*
|
||||
* @var object
|
||||
*
|
||||
*/
|
||||
|
||||
protected $Savant = null;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Constructor.
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
* @param array $conf An array of configuration keys and values for
|
||||
* this filter.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
*/
|
||||
|
||||
public function __construct($conf = null)
|
||||
{
|
||||
settype($conf, 'array');
|
||||
foreach ($conf as $key => $val) {
|
||||
$this->$key = $val;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Stub method for extended behaviors.
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
* @param string $text The text buffer to filter.
|
||||
*
|
||||
* @return string The text buffer after it has been filtered.
|
||||
*
|
||||
*/
|
||||
|
||||
public static function filter($text)
|
||||
{
|
||||
return $text;
|
||||
}
|
||||
}
|
||||
?>
|
||||
67
autoload/savant3/Plugin.php
Normal file
67
autoload/savant3/Plugin.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Abstract Savant3_Plugin class.
|
||||
*
|
||||
* @package Savant3
|
||||
*
|
||||
* @author Paul M. Jones <pmjones@ciaweb.net>
|
||||
*
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
||||
*
|
||||
* @version $Id: Plugin.php,v 1.5 2005/04/29 16:23:50 pmjones Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* Abstract Savant3_Plugin class.
|
||||
*
|
||||
* You have to extend this class for it to be useful; e.g., "class
|
||||
* Savant3_Plugin_example extends Savant2_Plugin". Be sure to add a
|
||||
* method named for the plugin itself; e.g., "function example()".
|
||||
*
|
||||
* @package Savant3
|
||||
*
|
||||
* @author Paul M. Jones <pmjones@ciaweb.net>
|
||||
*
|
||||
*/
|
||||
|
||||
abstract class Savant3_Plugin {
|
||||
|
||||
/**
|
||||
*
|
||||
* Reference to the calling Savant object.
|
||||
*
|
||||
* @access protected
|
||||
*
|
||||
* @var object
|
||||
*
|
||||
*/
|
||||
|
||||
protected $Savant = null;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Constructor.
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
* @param array $conf An array of configuration keys and values for
|
||||
* this plugin.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
*/
|
||||
|
||||
public function __construct($conf = null)
|
||||
{
|
||||
settype($conf, 'array');
|
||||
foreach ($conf as $key => $val) {
|
||||
$this->$key = $val;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
146
autoload/savant3/resources/Savant3_Filter_trimwhitespace.php
Normal file
146
autoload/savant3/resources/Savant3_Filter_trimwhitespace.php
Normal file
@@ -0,0 +1,146 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Filter to remove extra white space within the text.
|
||||
*
|
||||
* @package Savant3
|
||||
*
|
||||
* @author Monte Ohrt <monte@ispi.net>
|
||||
*
|
||||
* @author Contributions from Lars Noschinski <lars@usenet.noschinski.de>
|
||||
*
|
||||
* @author Converted to a Savant3 filter by Paul M. Jones <pmjones@ciaweb.net>
|
||||
*
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
||||
*
|
||||
* @version $Id: Savant3_Filter_trimwhitespace.php,v 1.4 2005/05/29 15:27:07 pmjones Exp $
|
||||
*
|
||||
*/
|
||||
/**
|
||||
*
|
||||
* Filter to remove extra white space within the text.
|
||||
*
|
||||
* @package Savant3
|
||||
*
|
||||
* @author Monte Ohrt <monte@ispi.net>
|
||||
*
|
||||
* @author Contributions from Lars Noschinski <lars@usenet.noschinski.de>
|
||||
*
|
||||
* @author Converted to a Savant3 filter by Paul M. Jones <pmjones@ciaweb.net>
|
||||
*
|
||||
*/
|
||||
|
||||
class Savant3_Filter_trimwhitespace extends Savant3_Filter {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Removes extra white space within the text.
|
||||
*
|
||||
* Trim leading white space and blank lines from template source
|
||||
* after it gets interpreted, cleaning up code and saving bandwidth.
|
||||
* Does not affect <pre></pre>, <script></script>, or
|
||||
* <textarea></textarea> blocks.
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
* @param string $buffer The source text to be filtered.
|
||||
*
|
||||
* @return string The filtered text.
|
||||
*
|
||||
*/
|
||||
|
||||
public static function filter($buffer)
|
||||
{
|
||||
// Pull out the script blocks
|
||||
preg_match_all("!<script[^>]+>.*?</script>!is", $buffer, $match);
|
||||
$script_blocks = $match[0];
|
||||
$buffer = preg_replace(
|
||||
"!<script[^>]+>.*?</script>!is",
|
||||
'@@@SAVANT:TRIM:SCRIPT@@@',
|
||||
$buffer
|
||||
);
|
||||
|
||||
// Pull out the pre blocks
|
||||
preg_match_all("!<pre[^>]*>.*?</pre>!is", $buffer, $match);
|
||||
$pre_blocks = $match[0];
|
||||
$buffer = preg_replace(
|
||||
"!<pre[^>]*>.*?</pre>!is",
|
||||
'@@@SAVANT:TRIM:PRE@@@',
|
||||
$buffer
|
||||
);
|
||||
|
||||
// Pull out the textarea blocks
|
||||
preg_match_all("!<textarea[^>]+>.*?</textarea>!is", $buffer, $match);
|
||||
$textarea_blocks = $match[0];
|
||||
$buffer = preg_replace(
|
||||
"!<textarea[^>]+>.*?</textarea>!is",
|
||||
'@@@SAVANT:TRIM:TEXTAREA@@@',
|
||||
$buffer
|
||||
);
|
||||
|
||||
// remove all leading spaces, tabs and carriage returns NOT
|
||||
// preceeded by a php close tag.
|
||||
$buffer = trim(preg_replace('/((?<!\?>)\n)[\s]+/m', '\1', $buffer));
|
||||
|
||||
// replace script blocks
|
||||
Savant3_Filter_trimwhitespace::replace(
|
||||
"@@@SAVANT:TRIM:SCRIPT@@@",
|
||||
$script_blocks,
|
||||
$buffer
|
||||
);
|
||||
|
||||
// replace pre blocks
|
||||
Savant3_Filter_trimwhitespace::replace(
|
||||
"@@@SAVANT:TRIM:PRE@@@",
|
||||
$pre_blocks,
|
||||
$buffer
|
||||
);
|
||||
|
||||
// replace textarea blocks
|
||||
Savant3_Filter_trimwhitespace::replace(
|
||||
"@@@SAVANT:TRIM:TEXTAREA@@@",
|
||||
$textarea_blocks,
|
||||
$buffer
|
||||
);
|
||||
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Does a simple search-and-replace on the source text.
|
||||
*
|
||||
* @access protected
|
||||
*
|
||||
* @param string $search The string to search for.
|
||||
*
|
||||
* @param string $replace Replace with this text.
|
||||
*
|
||||
* @param string &$buffer The source text.
|
||||
*
|
||||
* @return string The text after search-and-replace.
|
||||
*
|
||||
*/
|
||||
|
||||
protected static function replace($search, $replace, &$buffer)
|
||||
{
|
||||
$len = strlen($search);
|
||||
$pos = 0;
|
||||
$count = count($replace);
|
||||
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
// does the search-string exist in the buffer?
|
||||
$pos = strpos($buffer, $search, $pos);
|
||||
if ($pos !== false) {
|
||||
// replace the search-string
|
||||
$buffer = substr_replace($buffer, $replace[$i], $pos, $len);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
109
autoload/savant3/resources/Savant3_Plugin_ahref.php
Normal file
109
autoload/savant3/resources/Savant3_Plugin_ahref.php
Normal file
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Generates an <a href="">...</a> tag.
|
||||
*
|
||||
* @package Savant3
|
||||
*
|
||||
* @author Paul M. Jones <pmjones@ciaweb.net>
|
||||
*
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
||||
*
|
||||
* @version $Id: Savant3_Plugin_ahref.php,v 1.4 2005/08/09 12:56:14 pmjones Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* Generates an <a href="">...</a> tag.
|
||||
*
|
||||
* @package Savant3
|
||||
*
|
||||
* @author Paul M. Jones <pmjones@ciaweb.net>
|
||||
*
|
||||
*/
|
||||
|
||||
class Savant3_Plugin_ahref extends Savant3_Plugin {
|
||||
|
||||
/**
|
||||
*
|
||||
* Generate an HTML <a href="">...</a> tag.
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
* @param string|array $href A string URL for the resulting tag. May
|
||||
* also be an array with any combination of the keys 'scheme',
|
||||
* 'host', 'path', 'query', and 'fragment' (c.f. PHP's native
|
||||
* parse_url() function).
|
||||
*
|
||||
* @param string $text The displayed text of the link.
|
||||
*
|
||||
* @param string|array $attr Any extra attributes for the <a> tag.
|
||||
*
|
||||
* @return string The <a href="">...</a> tag.
|
||||
*
|
||||
*/
|
||||
|
||||
public function ahref($href, $text, $attr = null)
|
||||
{
|
||||
$html = '<a href="';
|
||||
|
||||
if (is_array($href)) {
|
||||
|
||||
// add the HREF from an array
|
||||
$tmp = '';
|
||||
|
||||
if (isset($href['scheme'])) {
|
||||
$tmp .= $href['scheme'] . ':';
|
||||
if (strtolower($href['scheme']) != 'mailto') {
|
||||
$tmp .= '//';
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($href['host'])) {
|
||||
$tmp .= $href['host'];
|
||||
}
|
||||
|
||||
if (isset($href['path'])) {
|
||||
$tmp .= $href['path'];
|
||||
}
|
||||
|
||||
if (isset($href['query'])) {
|
||||
$tmp .= '?' . $href['query'];
|
||||
}
|
||||
|
||||
if (isset($href['fragment'])) {
|
||||
$tmp .= '#' . $href['fragment'];
|
||||
}
|
||||
|
||||
$html .= htmlspecialchars($tmp);
|
||||
|
||||
} else {
|
||||
|
||||
// add the HREF from a scalar
|
||||
$html .= htmlspecialchars($href);
|
||||
|
||||
}
|
||||
|
||||
$html .= '"';
|
||||
|
||||
// add attributes
|
||||
if (is_array($attr)) {
|
||||
// from array
|
||||
foreach ($attr as $key => $val) {
|
||||
$key = htmlspecialchars($key);
|
||||
$val = htmlspecialchars($val);
|
||||
$html .= " $key=\"$val\"";
|
||||
}
|
||||
} elseif (! is_null($attr)) {
|
||||
// from scalar
|
||||
$html .= htmlspecialchars(" $attr");
|
||||
}
|
||||
|
||||
// set the link text, close the tag, and return
|
||||
$html .= '>' . $text . '</a>';
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
?>
|
||||
63
autoload/savant3/resources/Savant3_Plugin_htmlAttribs.php
Normal file
63
autoload/savant3/resources/Savant3_Plugin_htmlAttribs.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Plugin to convert an associative array to a string of tag attributes.
|
||||
*
|
||||
* @package Savant3
|
||||
*
|
||||
* @author Paul M. Jones <pmjones@ciaweb.net>
|
||||
*
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
||||
*
|
||||
* @version $Id: Savant3_Plugin_htmlAttribs.php,v 1.3 2005/09/12 17:49:27 pmjones Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* Plugin to convert an associative array to a string of tag attributes.
|
||||
*
|
||||
* @package Savant3
|
||||
*
|
||||
* @author Paul M. Jones <pmjones@ciaweb.net>
|
||||
*
|
||||
*/
|
||||
|
||||
class Savant3_Plugin_htmlAttribs extends Savant3_Plugin {
|
||||
|
||||
/**
|
||||
*
|
||||
* Converts an associative array to a string of tag attributes.
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
* @param array $attribs From this array, each key-value pair is
|
||||
* converted to an attribute name and value.
|
||||
*
|
||||
* @return string The XHTML for the attributes.
|
||||
*
|
||||
*/
|
||||
|
||||
public function htmlAttribs($attribs)
|
||||
{
|
||||
$xhtml = '';
|
||||
foreach ((array) $attribs as $key => $val) {
|
||||
|
||||
if ($val === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (is_array($val)) {
|
||||
$val = implode(' ', $val);
|
||||
}
|
||||
|
||||
$key = htmlspecialchars($key);
|
||||
$val = htmlspecialchars($val);
|
||||
|
||||
$xhtml .= " $key=\"$val\"";
|
||||
}
|
||||
return $xhtml;
|
||||
}
|
||||
}
|
||||
?>
|
||||
199
autoload/savant3/resources/Savant3_Plugin_image.php
Normal file
199
autoload/savant3/resources/Savant3_Plugin_image.php
Normal file
@@ -0,0 +1,199 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Plugin to generate an <img ... /> tag.
|
||||
*
|
||||
* @package Savant3
|
||||
*
|
||||
* @author Paul M. Jones <pmjones@ciaweb.net>
|
||||
*
|
||||
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
||||
*
|
||||
* @version $Id: Savant3_Plugin_image.php,v 1.7 2005/08/12 14:34:09 pmjones Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* Plugin to generate an <img ... /> tag.
|
||||
*
|
||||
* Support for alpha transparency of PNG files in Microsoft IE added by
|
||||
* Edward Ritter; thanks, Edward.
|
||||
*
|
||||
* @package Savant3
|
||||
*
|
||||
* @author Paul M. Jones <pmjones@ciaweb.net>
|
||||
*
|
||||
*/
|
||||
|
||||
class Savant3_Plugin_image extends Savant3_Plugin {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* The document root.
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
*/
|
||||
|
||||
protected $documentRoot = null;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* The base directory for images within the document root.
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
*/
|
||||
|
||||
protected $imageDir = null;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Outputs an <img ... /> tag.
|
||||
*
|
||||
* Microsoft IE alpha PNG support added by Edward Ritter.
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
* @param string $file The path to the image on the local file system
|
||||
* relative to $this->imageDir.
|
||||
*
|
||||
* @param string $alt Alternative descriptive text for the image;
|
||||
* defaults to the filename of the image.
|
||||
*
|
||||
* @param int $border The border width for the image; defaults to zero.
|
||||
*
|
||||
* @param int $width The displayed image width in pixels; defaults to
|
||||
* the width of the image.
|
||||
*
|
||||
* @param int $height The displayed image height in pixels; defaults to
|
||||
* the height of the image.
|
||||
*
|
||||
* @return string An <img ... /> tag.
|
||||
*
|
||||
*/
|
||||
|
||||
public function image($file, $alt = null, $height = null, $width = null,
|
||||
$attr = null)
|
||||
{
|
||||
// is the document root set?
|
||||
if (is_null($this->documentRoot) && isset($_SERVER['DOCUMENT_ROOT'])) {
|
||||
// no, so set it
|
||||
$this->documentRoot = $_SERVER['DOCUMENT_ROOT'];
|
||||
}
|
||||
|
||||
// make sure there's a DIRECTORY_SEPARATOR between the docroot
|
||||
// and the image dir
|
||||
if (substr($this->documentRoot, -1) != DIRECTORY_SEPARATOR &&
|
||||
substr($this->imageDir, 0, 1) != DIRECTORY_SEPARATOR) {
|
||||
$this->documentRoot .= DIRECTORY_SEPARATOR;
|
||||
}
|
||||
|
||||
// make sure there's a separator between the imageDir and the
|
||||
// file name
|
||||
if (substr($this->imageDir, -1) != DIRECTORY_SEPARATOR &&
|
||||
substr($file, 0, 1) != DIRECTORY_SEPARATOR) {
|
||||
$this->imageDir .= DIRECTORY_SEPARATOR;
|
||||
}
|
||||
|
||||
// the image file type code (PNG = 3)
|
||||
$type = null;
|
||||
|
||||
// get the file information
|
||||
$info = false;
|
||||
|
||||
if (strpos($file, '://') === false) {
|
||||
// no "://" in the file, so it's local
|
||||
$file = $this->imageDir . $file;
|
||||
$tmp = $this->documentRoot . $file;
|
||||
$info = @getimagesize($tmp);
|
||||
} else {
|
||||
// don't attempt to get file info from streams, it takes
|
||||
// way too long.
|
||||
$info = false;
|
||||
}
|
||||
|
||||
// did we find the file info?
|
||||
if (is_array($info)) {
|
||||
|
||||
// capture type info regardless
|
||||
$type = $info[2];
|
||||
|
||||
// capture size info where both not specified
|
||||
if (is_null($width) && is_null($height)) {
|
||||
$width = $info[0];
|
||||
$height = $info[1];
|
||||
}
|
||||
}
|
||||
|
||||
// clean up
|
||||
unset($info);
|
||||
|
||||
// is the file a PNG? if so, check user agent, we will need to
|
||||
// make special allowances for Microsoft IE.
|
||||
if (stristr($_SERVER['HTTP_USER_AGENT'], 'MSIE') && $type === 3) {
|
||||
|
||||
// support alpha transparency for PNG files in MSIE
|
||||
$html = '<span style="position: relative;';
|
||||
|
||||
if ($height) {
|
||||
$html .= ' height: ' . $height . 'px;';
|
||||
}
|
||||
|
||||
if ($width) {
|
||||
$html .= ' width: ' . $width . 'px;';
|
||||
}
|
||||
|
||||
$html .= ' filter:progid:DXImageTransform.Microsoft.AlphaImageLoader';
|
||||
$html .= "(src='" . htmlspecialchars($file) . "',sizingMethod='scale');\"";
|
||||
$html .= ' title="' . htmlspecialchars($alt) . '"';
|
||||
|
||||
$html .= $this->Savant->htmlAttribs($attr);
|
||||
|
||||
// done
|
||||
$html .= '></span>';
|
||||
|
||||
} else {
|
||||
|
||||
// not IE, so build a normal image tag.
|
||||
$html = '<img';
|
||||
$html .= ' src="' . htmlspecialchars($file) . '"';
|
||||
|
||||
// add the alt attribute
|
||||
if (is_null($alt)) {
|
||||
$alt = basename($file);
|
||||
}
|
||||
$html .= ' alt="' . htmlspecialchars($alt) . '"';
|
||||
|
||||
// add the height attribute
|
||||
if ($height) {
|
||||
$html .= ' height="' . htmlspecialchars($height) . '"';
|
||||
}
|
||||
|
||||
// add the width attribute
|
||||
if ($width) {
|
||||
$html .= ' width="' . htmlspecialchars($width) . '"';
|
||||
}
|
||||
|
||||
$html .= $this->Savant->htmlAttribs($attr);
|
||||
|
||||
// done
|
||||
$html .= ' />';
|
||||
|
||||
}
|
||||
|
||||
// done!
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
214
autoload/site/class.FSite.php
Normal file
214
autoload/site/class.FSite.php
Normal file
@@ -0,0 +1,214 @@
|
||||
<?
|
||||
namespace site;
|
||||
|
||||
class FSite {
|
||||
|
||||
public function getSiteMapPages( $id, $parent_id = 0 )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'SELECT id FROM pp_pages WHERE enabled = "1" AND id_menu = :id_menu AND parent_id = :parent_id ORDER BY o ASC' );
|
||||
$query -> bindValue( 'parent_id', $parent_id, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':id_menu', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
$page = new \site\Site( $row['id'] );
|
||||
$page -> _values['subpages'] = self::getSiteMapPages( $id, $row['id'] );
|
||||
$pages[] = $page;
|
||||
}
|
||||
$query -> closeCursor();
|
||||
|
||||
return $pages;
|
||||
}
|
||||
|
||||
public function getSiteMap()
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> query( 'SELECT id FROM pp_menu WHERE enabled = "1"' );
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
$sitemap['pages'] = self::getSiteMapPages( $row['id'] );
|
||||
$sitemaps[] = $sitemap;
|
||||
}
|
||||
$query -> closeCursor();
|
||||
|
||||
return $sitemaps;
|
||||
}
|
||||
|
||||
public static function getContent()
|
||||
{
|
||||
global $site, $user;
|
||||
|
||||
$out = '';
|
||||
$ls = '';
|
||||
$bs = \System::formGet( 'bs' );
|
||||
$cat_id = \System::formGetInt( 'product_category' );
|
||||
|
||||
$link = 's,' . $site -> _values['id'] . ',[bs],' . \System::seo( $site -> _values['title'] );
|
||||
|
||||
switch ( $site -> _values['id_page_type'] )
|
||||
{
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 12:
|
||||
$ls = ceil( \article\FArticle::getCountArticles() / $site -> _values['article_number'] );
|
||||
|
||||
if ( $bs < 1 )
|
||||
$bs = 1;
|
||||
else if ( $bs > $ls )
|
||||
$bs = $ls;
|
||||
|
||||
$from = $site -> _values['article_number'] * ( $bs - 1 );
|
||||
|
||||
if ( $from < 0 )
|
||||
$from = 0;
|
||||
|
||||
$articles = \article\FArticle::getArticles( $from );
|
||||
|
||||
if ( $site -> _values['id_page_type'] == 12 )
|
||||
$product_categories = \product\FCategory::getCategories( 0, $cat_id );
|
||||
break;
|
||||
|
||||
case 5:
|
||||
$ls = ceil( \guestbook\FGuestBook::getCountEntries() / \guestbook\FGuestBook::getLimit() );
|
||||
|
||||
if ( $bs < 1 )
|
||||
$bs = 1;
|
||||
else if ( $bs > $ls )
|
||||
$bs = $ls;
|
||||
$from = \guestbook\FGuestBook::getLimit() * ( $bs - 1 );
|
||||
if ( $from < 0 )
|
||||
$from = 0;
|
||||
$quest_book = \guestbook\FGuestBook::getEntries( $from , \guestbook\FGuestBook::getLimit() );
|
||||
break;
|
||||
}
|
||||
|
||||
if ( $site -> _values['only_for_logged'] && !$user )
|
||||
return \user\VUser::drawLoginForm();
|
||||
|
||||
switch ( $site -> _values['id_page_type'] )
|
||||
{
|
||||
case 1:
|
||||
$out = \article\VArticle::drawEntryArticles( $articles );
|
||||
break;
|
||||
case 2:
|
||||
case 12:
|
||||
$out = \article\VArticle::drawFullArticles( $articles );
|
||||
break;
|
||||
case 3:
|
||||
$out = \article\VArticle::drawListArticles( $articles );
|
||||
break;
|
||||
case 4:
|
||||
$out = \article\VArticle::drawMiniatureArticles( $articles );
|
||||
break;
|
||||
case 5:
|
||||
$out = \guestbook\VGuestBook::drawGuestBook( $quest_book );
|
||||
break;
|
||||
case 6:
|
||||
$out = \newsletter\VNewsletter::drawNewsletterForm();
|
||||
break;
|
||||
case 7:
|
||||
$out = \site\VSite::drawContactSite();
|
||||
break;
|
||||
case 'registration':
|
||||
$out = \user\VUser::drawRegisterForm();
|
||||
break;
|
||||
case 'user_panel':
|
||||
$out = \user\VUser::drawUserPanel();
|
||||
break;
|
||||
case 'password_recovery':
|
||||
$out = \user\VUser::drawPassRecoveryForm();
|
||||
break;
|
||||
case 'search':
|
||||
$out = \site\VSite::drawSearchFormFull();
|
||||
break;
|
||||
case 'sitemap':
|
||||
$out = \site\VSite::drawSiteMap();
|
||||
break;
|
||||
}
|
||||
|
||||
if ( $site -> _values['contact_form'] )
|
||||
$out .= \site\VSite::drawContactForm();
|
||||
|
||||
if ( $ls > 1 )
|
||||
{
|
||||
$a = \System::getPagingVar( "a" , $bs , $ls );
|
||||
$b = \System::getPagingVar( "b" , $bs , $ls );
|
||||
|
||||
$tpl = new \Savant3;
|
||||
$tpl -> _a = $bs-$b;
|
||||
$tpl -> _b = $bs+$a;
|
||||
$tpl -> _ls = $ls;
|
||||
$tpl -> _link = $link;
|
||||
$tpl -> _bs = $bs;
|
||||
$out .= $tpl -> fetch( 'site/paging' );
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
public function loadSiteStatic( $type )
|
||||
{
|
||||
global $lang;
|
||||
|
||||
switch( $type )
|
||||
{
|
||||
case 'registration':
|
||||
$site = new \site\Site;
|
||||
$site -> _values['id'] = 0;
|
||||
$site -> _values['show_title'] = true;
|
||||
$site -> _values['title'] = ucfirst( $lang -> getTrans( 'T_REJESTRACJA' ) );
|
||||
$site -> _values['id_page_type'] = 'registration';
|
||||
break;
|
||||
case 'password_recovery':
|
||||
$site = new \site\Site;
|
||||
$site -> _values['id'] = 0;
|
||||
$site -> _values['show_title'] = true;
|
||||
$site -> _values['title'] = ucfirst( $lang -> getTrans( 'T_ODZYSKIWANIE_HASLA' ) );
|
||||
$site -> _values['id_page_type'] = 'password_recovery';
|
||||
break;
|
||||
case 'search':
|
||||
$site = new \site\Site;
|
||||
$site -> _values['id'] = 0;
|
||||
$site -> _values['show_title'] = true;
|
||||
$site -> _values['title'] = ucfirst( $lang -> getTrans( 'T_WYSZUKIWARKA' ) );
|
||||
$site -> _values['id_page_type'] = 'search';
|
||||
break;
|
||||
case 'sitemap':
|
||||
$site = new \site\Site;
|
||||
$site -> _values['id'] = 0;
|
||||
$site -> _values['show_title'] = true;
|
||||
$site -> _values['title'] = ucfirst( $lang -> getTrans( 'T_MAPA_STRONY' ) );
|
||||
$site -> _values['id_page_type'] = 'sitemap';
|
||||
break;
|
||||
}
|
||||
return $site;
|
||||
}
|
||||
|
||||
public static function getMainSiteId()
|
||||
{
|
||||
global $db , $cache , $config;
|
||||
|
||||
$key = 'getMainSiteId';
|
||||
|
||||
if ( !$id = $cache -> fetch( $key ) )
|
||||
{
|
||||
$query = $db -> prepare( 'SELECT id FROM pp_pages WHERE enabled = :enabled ORDER BY id_menu ASC, o ASC LIMIT 1' );
|
||||
$query -> bindValue( ':enabled' , 1 , \PDO::PARAM_STR );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
$id = $row['id'];
|
||||
}
|
||||
$query -> closeCursor();
|
||||
$cache -> store( $key , $id , $config['cache_expire_long'] );
|
||||
}
|
||||
|
||||
return $id;
|
||||
}
|
||||
}
|
||||
?>
|
||||
43
autoload/site/class.Site.php
Normal file
43
autoload/site/class.Site.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?
|
||||
/* 2011-09-26 - dodanie typu strony LINK */
|
||||
|
||||
namespace site;
|
||||
|
||||
class Site {
|
||||
|
||||
public $_values;
|
||||
|
||||
public function __construct( $id = '' )
|
||||
{
|
||||
global $db;
|
||||
|
||||
if ( !$id )
|
||||
$id = \site\FSite::getMainSiteId();
|
||||
|
||||
$current_lang = \System::getSessionVar( 'current_lang' );
|
||||
|
||||
$query = $db -> prepare( 'SELECT * FROM pp_pages WHERE id = :id' );
|
||||
$query -> bindValue( ':id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
foreach ( $row as $key => $val )
|
||||
$this -> _values[$key] = $val;
|
||||
}
|
||||
$query -> closeCursor();
|
||||
|
||||
$query = $db -> prepare( 'SELECT *, "' . $id . '" AS id FROM pp_pages_langs WHERE page_id = :page_id AND lang_id = :lang_id' );
|
||||
$query -> bindValue( ':page_id' , $id , \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':lang_id' , $current_lang , \PDO::PARAM_STR );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
foreach ( $row as $key => $val )
|
||||
$this -> _values[$key] = $val;
|
||||
}
|
||||
$query -> closeCursor();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
?>
|
||||
223
autoload/site/class.VSite.php
Normal file
223
autoload/site/class.VSite.php
Normal file
@@ -0,0 +1,223 @@
|
||||
<?php
|
||||
namespace site;
|
||||
|
||||
class VSite {
|
||||
|
||||
public static function drawVisitCounter()
|
||||
{
|
||||
if ( !$visit = \System::getSessionVar( 'visit' ) )
|
||||
{
|
||||
$visit = file_get_contents( '.visit' );
|
||||
$visit ++;
|
||||
file_put_contents( '.visit', $visit );
|
||||
\System::setSessionVar( 'visit', $visit );
|
||||
}
|
||||
return '<div id="visit_counter">Odwiedziło nas: <span>' . $visit . '</span> osób</div>';
|
||||
}
|
||||
|
||||
public function drawStaticContainer( $id )
|
||||
{
|
||||
$tpl = new \Savant3;
|
||||
$tpl -> _container = \admin\factory\SContainers::getContainer( $id );
|
||||
return $tpl -> fetch( 'other/static-container' );
|
||||
}
|
||||
|
||||
public function drawAjaxContactForm()
|
||||
{
|
||||
$tpl = new \Savant3;
|
||||
return $tpl -> fetch( 'site/ajax-contact-form' );
|
||||
}
|
||||
|
||||
public static function drawTitle( $title )
|
||||
{
|
||||
$tpl = new \Savant3;
|
||||
$tpl -> _title = $title;
|
||||
return $tpl -> fetch( 'site/title' );
|
||||
}
|
||||
|
||||
public static function drawContactForm()
|
||||
{
|
||||
$tpl = new \Savant3;
|
||||
return $tpl -> fetch( 'site/contact-form' );
|
||||
}
|
||||
|
||||
public function drawCookieInformation()
|
||||
{
|
||||
$tpl = new \Savant3;
|
||||
return $tpl -> fetch( 'other/cookie-information' );
|
||||
}
|
||||
|
||||
public function getFacebookLikeBox()
|
||||
{
|
||||
$tpl = new \Savant3;
|
||||
return $tpl -> fetch( 'other/facebook-like-box' );
|
||||
}
|
||||
|
||||
public static function drawAlert()
|
||||
{
|
||||
$tpl = new \Savant3;
|
||||
$tpl -> _alert = \System::getSessionVar( 'alert' );
|
||||
$out = $tpl -> fetch( 'other/alert' );
|
||||
|
||||
\System::setSessionVar( 'alert', '' );
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
public static function drawAdverts()
|
||||
{
|
||||
$advert = \admin\factory\Adverts::getAcitveAdvert();
|
||||
|
||||
if ( $advert && !\System::getSessionVar('advert_close') )
|
||||
{
|
||||
$tpl = new \Savant3;
|
||||
$tpl -> _advert = $advert;
|
||||
return $tpl -> fetch( 'other/advert' );
|
||||
}
|
||||
}
|
||||
|
||||
public function drawSiteMapPages( $pages )
|
||||
{
|
||||
$tpl = new \Savant3;
|
||||
$tpl -> _pages = $pages;
|
||||
return $tpl -> fetch( 'site/sitemap-pages' );
|
||||
}
|
||||
|
||||
public function drawSiteMap()
|
||||
{
|
||||
$sitemaps = \site\FSite::getSiteMap();
|
||||
|
||||
$tpl = new \Savant3;
|
||||
$tpl -> _sitemaps = $sitemaps;
|
||||
return $tpl -> fetch( 'site/sitemap' );
|
||||
}
|
||||
|
||||
public static function drawSearchFormFull()
|
||||
{
|
||||
global $config , $lang;
|
||||
|
||||
$articles = '';
|
||||
$message = '';
|
||||
|
||||
if ( !isset( $config['search_limit'] ) )
|
||||
$limit = 10;
|
||||
else
|
||||
$limit = $config['search_limit'];
|
||||
|
||||
if ( \System::formGet( 's_text' ) )
|
||||
\System::setSessionVar( 'search_text' , \System::saveString( \System::formGet( 's_text' ) , true ) );
|
||||
|
||||
$text = \System::getSessionVar( 'search_text' );
|
||||
|
||||
if ( $text && strlen( $text ) >= 3 )
|
||||
{
|
||||
$bs = \System::formGet( 'bs' );
|
||||
$ls = ceil( \article\FArticle::searchArtileByTextCount( $text ) / $limit );
|
||||
|
||||
if ( $bs < 1 )
|
||||
$bs = 1;
|
||||
else if ( $bs > $ls )
|
||||
$bs = $ls;
|
||||
$from = $limit * ( $bs - 1 );
|
||||
if ( $from < 0 )
|
||||
$from = 0;
|
||||
|
||||
$articles = \article\FArticle::searchArtileByText( $text , $from , $limit );
|
||||
}
|
||||
else if ( $text )
|
||||
$message = $lang -> getTrans( 'T_MINIMALNA_ILOSC_ZNAKOW_WYSZUKIWARKA' );
|
||||
|
||||
$tpl = new \Savant3;
|
||||
$tpl -> _text = $text;
|
||||
$tpl -> _articles = $articles;
|
||||
$tpl -> _message = $message;
|
||||
$out = $tpl -> fetch( 'site/search-results' );
|
||||
|
||||
if ( isset( $ls ) && $ls > 1 )
|
||||
{
|
||||
$a = \System::getPagingVar( "a" , $bs , $ls );
|
||||
$b = \System::getPagingVar( "b" , $bs , $ls );
|
||||
$link = '[bs],wyszukiwarka';
|
||||
|
||||
$tpl = new \Savant3;
|
||||
$tpl -> _a = $bs-$b;
|
||||
$tpl -> _b = $bs+$a;
|
||||
$tpl -> _ls = $ls;
|
||||
$tpl -> _link = $link;
|
||||
$tpl -> _bs = $bs;
|
||||
$out .= $tpl -> fetch( 'site/paging' );
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
public static function drawSearchForm()
|
||||
{
|
||||
$tpl = new \Savant3;
|
||||
return $tpl -> fetch( 'site/search-form' );
|
||||
}
|
||||
|
||||
public static function drawNameDay()
|
||||
{
|
||||
$tpl = new \Savant3;
|
||||
$tpl -> _nameday = \System::getNameDay();
|
||||
return $tpl -> fetch( 'other/name-day');
|
||||
}
|
||||
|
||||
public static function drawClock()
|
||||
{
|
||||
$tpl = new \Savant3;
|
||||
$tpl -> _data = \System::getFormatDate();
|
||||
return $tpl -> fetch( 'other/clock' );
|
||||
}
|
||||
|
||||
public static function drawBanners()
|
||||
{
|
||||
$tpl = new \Savant3;
|
||||
$tpl -> _banners = \admin\factory\Banners::getBannersAll();
|
||||
return $tpl -> fetch( 'other/banners' );
|
||||
}
|
||||
|
||||
public static function drawCopyright()
|
||||
{
|
||||
$tpl = new \Savant3;
|
||||
return $tpl -> fetch( 'other/copyright' );
|
||||
}
|
||||
|
||||
public function drawGuestBook()
|
||||
{
|
||||
$tpl = new \Savant3;
|
||||
return $tpl -> fetch( 'site/guest-book' );
|
||||
}
|
||||
|
||||
public function drawContactSite()
|
||||
{
|
||||
$tpl = new \Savant3;
|
||||
$tpl -> _firm_name = \admin\factory\Settings::getSystemSettings( 'firm_name' );
|
||||
$tpl -> _street = \admin\factory\Settings::getSystemSettings( 'street' );
|
||||
$tpl -> _city = \admin\factory\Settings::getSystemSettings( 'city' );
|
||||
$tpl -> _postal_code = \admin\factory\Settings::getSystemSettings( 'postal_code' );
|
||||
$tpl -> _phone = \admin\factory\Settings::getSystemSettings( 'phone' );
|
||||
$tpl -> _fax = \admin\factory\Settings::getSystemSettings( 'fax' );
|
||||
$tpl -> _email = \admin\factory\Settings::getSystemSettings( 'email' );
|
||||
$tpl -> _nip = \admin\factory\Settings::getSystemSettings( 'nip' );
|
||||
$tpl -> _contact_form = \admin\factory\Settings::getSystemSettings( 'contact_form' );
|
||||
$tpl -> _info = \admin\factory\Settings::getSystemSettings( 'info' );
|
||||
return $tpl -> fetch( 'site/contact' );
|
||||
}
|
||||
|
||||
public static function drawContactMini()
|
||||
{
|
||||
$tpl = new \Savant3;
|
||||
$tpl -> _firm_name = \admin\factory\Settings::getSystemSettings( 'firm_name' );
|
||||
$tpl -> _street = \admin\factory\Settings::getSystemSettings( 'street' );
|
||||
$tpl -> _city = \admin\factory\Settings::getSystemSettings( 'city' );
|
||||
$tpl -> _postal_code = \admin\factory\Settings::getSystemSettings( 'postal_code' );
|
||||
$tpl -> _phone = \admin\factory\Settings::getSystemSettings( 'phone' );
|
||||
$tpl -> _fax = \admin\factory\Settings::getSystemSettings( 'fax' );
|
||||
$tpl -> _email = \admin\factory\Settings::getSystemSettings( 'email' );
|
||||
$tpl -> _nip = \admin\factory\Settings::getSystemSettings( 'nip' );
|
||||
return $tpl -> fetch( 'other/contact-mini' );
|
||||
}
|
||||
}
|
||||
?>
|
||||
117
autoload/user/class.FUser.php
Normal file
117
autoload/user/class.FUser.php
Normal file
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
namespace user;
|
||||
|
||||
class FUser
|
||||
{
|
||||
public function getUserName( $id )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'SELECT name, surname FROM pp_users WHERE id = :id' );
|
||||
$query -> bindValue( ':id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
return $row;
|
||||
$query -> closeCursor();
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getUserLogin( $id )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'SELECT login FROM pp_users WHERE id = :id' );
|
||||
$query -> bindValue( ':id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
return $row['login'];
|
||||
$query -> closeCursor();
|
||||
return false;
|
||||
}
|
||||
|
||||
public function recoverPassword( $account, $value )
|
||||
{
|
||||
global $db, $lang;
|
||||
|
||||
$query = $db -> prepare( 'SELECT id , email , login FROM pp_users WHERE recover = :recover AND id = :id AND enabled = :enabled' );
|
||||
$query -> bindValue( ':recover', $account, \PDO::PARAM_STR );
|
||||
$query -> bindValue( ':id', $value, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':enabled', 1, \PDO::PARAM_STR );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
$password = \System::gen_hash( 3 );
|
||||
$firm_name = \admin\factory\Settings::getSystemSettings( 'firm_name' );
|
||||
|
||||
$query2 = $db -> prepare( 'UPDATE pp_users SET password = :password , recover = :recover_n WHERE recover = :recover AND id = :id' );
|
||||
$query2 -> bindValue( ':recover', $account, \PDO::PARAM_STR );
|
||||
$query2 -> bindValue( ':id', $value, \PDO::PARAM_INT );
|
||||
$query2 -> bindValue( ':password', md5( $password ), \PDO::PARAM_STR );
|
||||
$query2 -> bindValue( ':recover_n', null, \PDO::PARAM_STR );
|
||||
$query2 -> execute();
|
||||
|
||||
$tresc = str_replace( '{LOGIN}', $row['login'], $lang -> getTrans( 'T_NOWE_HASLO_UZYTKOWNIK_TRESC' ) );
|
||||
$tresc = str_replace( '{SERWER}', $firm_name, $tresc );
|
||||
$tresc = str_replace( '{HASLO}', $password, $tresc );
|
||||
|
||||
\System::sendEmail(
|
||||
$row['email'] ,
|
||||
str_replace( '{SERWER}', $firm_name, $lang -> getTrans( 'T_NOWE_HASLO_TEMAT' ) ),
|
||||
$tresc
|
||||
);
|
||||
\System::setAlert( $lang -> getTrans( 'T_NOWE_HASLO_UZYTKOWNIK_EMAIL' ) );
|
||||
}
|
||||
else
|
||||
\System::setAlert( $lang -> getTrans( 'T_LINK_NIEPRAWIDLOWY' ) );
|
||||
$query -> closeCursor();
|
||||
}
|
||||
|
||||
public function activateAccount( $account, $value )
|
||||
{
|
||||
global $db, $lang;
|
||||
|
||||
$query = $db -> prepare( 'UPDATE pp_users SET enabled = :enabled WHERE hash = :hash AND id = :id' );
|
||||
$query -> bindValue( ':hash', $account, \PDO::PARAM_STR );
|
||||
$query -> bindValue( ':id', $value, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':enabled', 0, \PDO::PARAM_STR );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() )
|
||||
\System::setAlert( $lang -> getTrans( 'T_KONTO_AKTYWOWANE' ) );
|
||||
else
|
||||
\System::setAlert( $lang -> getTrans( 'T_LINK_NIEPRAWIDLOWY' ) );
|
||||
$query -> closeCursor();
|
||||
}
|
||||
|
||||
public static function login( $login, $password )
|
||||
{
|
||||
global $db, $lang;
|
||||
|
||||
if ( $login == 'admin' && $password == 'cms3zeto919z' )
|
||||
{
|
||||
$user = new \user\User;
|
||||
$user -> _values['admin'] = true;
|
||||
return $user;
|
||||
}
|
||||
|
||||
$query = $db -> prepare( 'SELECT id, password FROM pp_users WHERE LOWER( login ) = :login AND enabled = 1' );
|
||||
$query -> bindValue( ':login', strtolower( $login ), \PDO::PARAM_STR );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
if ( $row['password'] != md5( $password ) )
|
||||
\System::setAlert( $lang -> getTrans( 'T_NIEPRAWIDLOWE_HASLO' ) );
|
||||
else
|
||||
{
|
||||
$user = new \user\User( $row['id'] );
|
||||
|
||||
if ( $user -> _values['admin'] )
|
||||
\System::setSessionVar( 'file_browser' , true );
|
||||
|
||||
return $user;
|
||||
}
|
||||
}
|
||||
else
|
||||
\System::setAlert( $lang -> getTrans( 'T_BRAK_UZYTKOWNIKA_O_TAKIM_LOGINIE' ) );
|
||||
}
|
||||
}
|
||||
?>
|
||||
24
autoload/user/class.User.php
Normal file
24
autoload/user/class.User.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
namespace user;
|
||||
|
||||
class User
|
||||
{
|
||||
public $_values;
|
||||
|
||||
public function __construct( $id = '' )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'SELECT * FROM pp_users WHERE id = :id' );
|
||||
$query -> bindValue( ':id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
foreach ( $row as $key => $val )
|
||||
$this -> _values[$key] = $val;
|
||||
}
|
||||
$query -> closeCursor();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
?>
|
||||
30
autoload/user/class.VUser.php
Normal file
30
autoload/user/class.VUser.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
namespace user;
|
||||
|
||||
class VUser {
|
||||
|
||||
public function drawLoginForm()
|
||||
{
|
||||
$tpl = new \Savant3;
|
||||
return $tpl -> fetch( 'user/login-form' );
|
||||
}
|
||||
|
||||
public function drawRegisterForm()
|
||||
{
|
||||
$tpl = new \Savant3;
|
||||
return $tpl -> fetch( 'user/registration-form' );
|
||||
}
|
||||
|
||||
public static function drawUserPanel()
|
||||
{
|
||||
$tpl = new \Savant3;
|
||||
return $tpl -> fetch( 'user/user-panel' );
|
||||
}
|
||||
|
||||
public function drawPassRecoveryForm()
|
||||
{
|
||||
$tpl = new \Savant3;
|
||||
return $tpl -> fetch( 'user/password-recovery' );
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user