first commit

This commit is contained in:
2024-11-21 14:26:28 +01:00
commit 78fe46c8a7
2082 changed files with 158662 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
.vscode/ftp-kr.sync.cache.json
upload/filemanager/landing/movie.mov

1943
.htaccess Normal file

File diff suppressed because it is too large Load Diff

17
.vscode/ftp-kr.json vendored Normal file
View File

@@ -0,0 +1,17 @@
{
"host": "serwer1574995.home.pl",
"username": "projectpro",
"password": "ProjectPro2025!",
"remotePath": "/autoinstalator/wordpress9",
"protocol": "ftp",
"port": 0,
"fileNameEncoding": "utf8",
"autoUpload": true,
"autoDelete": false,
"autoDownload": false,
"ignoreRemoteModification": true,
"ignore": [
".git",
"/.vscode"
]
}

17
.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,17 @@
{
"liveSassCompile.settings.formats": [
{
"format": "compressed",
"extensionName": ".css",
"savePath": "~/../style-css/",
"savePathSegmentKeys": null,
"savePathReplaceSegmentsWith": null
}
],
"liveSassCompile.settings.generateMap": true,
"liveSassCompile.settings.autoprefix": "defaults",
"liveSassCompile.settings.watchOnLaunch": true,
"liveSassCompile.settings.includeItems": [
"/layout/style-scss/*.scss"
]
}

12
.vscode/sftp.json vendored Normal file
View File

@@ -0,0 +1,12 @@
{
"name": "serwer1574995.home.pl",
"host": "serwer1574995.home.pl",
"protocol": "ftp",
"port": 21,
"username": "projectpro",
"password": "ProjectPro2025!",
"remotePath": "/autoinstalator/wordpress9",
"uploadOnSave": false,
"useTempFile": false,
"openSsh": false
}

Binary file not shown.

38
admin/ajax.php Normal file
View File

@@ -0,0 +1,38 @@
<?
error_reporting( 0 );
function __autoload_my_classes( $classname )
{
$q = explode( '\\' , $classname );
$c = array_pop( $q );
$f = '../autoload/' . implode( '/' , $q ) . '/class.' . $c . '.php';
if ( $c == 'Savant3' )
{
require_once( '../autoload/Savant3.php' );
return true;
}
if ( file_exists( $f ) )
require_once( $f );
}
spl_autoload_register( '__autoload_my_classes' );
require_once '../config.php';
require_once '../libraries/medoo/medoo.php';
require_once '../libraries/grid/config.php';
date_default_timezone_set('Europe/Warsaw');
session_start();
$mdb = new medoo( [
'database_type' => 'mysql',
'database_name' => $database['name'],
'server' => $database['host'],
'username' => $database['user'],
'password' => $database['password'],
'charset' => 'utf8'
] );
require_once 'ajax/pages.php';
require_once 'ajax/articles.php';
require_once 'ajax/users.php';
require_once 'ajax/newsletter.php';
?>

86
admin/index.php Normal file
View File

@@ -0,0 +1,86 @@
<?
if ( file_exists( 'ip.conf' ) )
{
$ips = file_get_contents( 'ip.conf' );
$ips = preg_split( "/\\r\\n|\\r|\\n/", $ips );
$ips = array_filter( $ips );
if ( is_array( $ips ) and !empty( $ips ) )
{
if ( !in_array( $_SERVER['REMOTE_ADDR'], $ips ) )
die( 'Brak dostępu.' );
}
}
error_reporting( 0 );
function __autoload_my_classes( $classname )
{
$q = explode( '\\' , $classname );
$c = array_pop( $q );
$f = '../autoload/' . implode( '/' , $q ) . '/class.' . $c . '.php';
if ( file_exists( $f ) )
require_once( $f );
}
spl_autoload_register( '__autoload_my_classes' );
require_once '../config.php';
require_once '../libraries/medoo/medoo.php';
require_once '../libraries/grid/config.php';
date_default_timezone_set( 'Europe/Warsaw' );
$settings = \front\factory\Settings::settings_details();
if ( file_exists( 'config.php' ) )
include 'config.php';
session_start();
if ( !isset( $_SESSION['check'] ) )
{
session_regenerate_id();
$_SESSION['check'] = true;
$_SESSION['ip'] = $_SERVER['REMOTE_ADDR'];
}
if ( $_SESSION['ip'] !== $_SERVER['REMOTE_ADDR'] )
{
session_destroy();
header( 'Location: /admin/' );
exit;
}
$mdb = new medoo( [
'database_type' => 'mysql',
'database_name' => $database['name'],
'server' => $database['host'],
'username' => $database['user'],
'password' => $database['password'],
'charset' => 'utf8'
] );
$user = \S::get_session( 'user' , true );
\admin\Site::special_actions();
$domain = preg_replace( '#^(http(s)?://)?w{3}\.#', '$1', $_SERVER['SERVER_NAME'] );
$cookie_name = str_replace( '.', '-', $domain );
if ( isset( $_COOKIE[$cookie_name] ) && !isset( $_SESSION['user'] ) )
{
$obj = json_decode( $_COOKIE[$cookie_name] );
$login = $obj -> {'login'};
$password = $obj -> {'hash'};
if ( $mdb -> get( 'pp_users', '*',
[ 'AND' =>
[ 'login' => $login, 'status' => 1, 'password' => $password,
'OR' => [ 'active_to[>=]' => date( 'Y-m-d' ), 'active_to' => null ]
]
] ) )
{
\S::set_session( 'user', \admin\factory\Users::details( $login ) );
header( 'Location: /admin/articles/view_list/' );
exit;
}
}
echo \admin\view\Page::show();
?>

207
ajax.php Normal file
View File

@@ -0,0 +1,207 @@
<?php
error_reporting( E_ALL ^ E_NOTICE ^ E_STRICT ^ E_WARNING ^ E_DEPRECATED );
function __autoload_my_classes( $classname )
{
$q = explode( '\\' , $classname );
$c = array_pop( $q );
$f = 'autoload/' . implode( '/' , $q ) . '/class.' . $c . '.php';
if ( file_exists( $f ) )
require_once( $f );
}
spl_autoload_register( '__autoload_my_classes' );
date_default_timezone_set( 'Europe/Warsaw' );
require_once 'config.php';
require_once 'libraries/medoo/medoo.php';
session_start();
$mdb = new medoo( [
'database_type' => 'mysql',
'database_name' => $database['name'],
'server' => $database['host'],
'username' => $database['user'],
'password' => $database['password'],
'charset' => 'utf8'
] );
if ( !$lang_id = \S::get_session( 'current-lang' ) )
{
$lang_id = \front\factory\Languages::default_language();
\S::set_session( 'current-lang', $lang_id );
}
if ( !$lang = \S::get_session( 'lang' ) )
{
$lang = \front\factory\Languages::lang_translations();
\S::set_session( 'lang', $lang );
}
\front\controls\Site::check_url_params();
if ( !$settings = \S::get_session( 'settings' ) )
{
$settings = \front\factory\Settings::settings_details();
\S::set_session( 'settings', $settings );
}
if ( \S::get( 'a' ) == 'calendar' )
{
echo \front\view\Site::calendar( \S::get( 'month' ), \S::get( 'year' ), true );
exit;
}
if ( \S::get( 'a' ) == 'widget-phone-now' )
{
$response = [ 'status' => 'error' ];
if ( \S::get( 'phone' ) )
{
if ( \S::send_email(
$settings['contact_email'],
'Prośba o oddzwonienie',
'<p>Nr telefonu: ' . \S::get( 'phone' ) . '</p>',
$settings['contact_email']
) )
$response = [ 'status' => 'ok' ];
}
echo json_encode( $response );
exit;
}
if ( \S::get( 'a' ) == 'contact_form' )
{
$response = [ 'status' => 'error' ];
if ( \S::get( 'email' ) )
{
if ( \S::send_email(
$settings['contact_email'],
\S::get( 'subject' ),
'<p>Nr telefonu: ' . \S::get( 'phone' ) . '</p>'
. '<p>Email: ' . \S::get( 'email' ) . '</p>'
. '<p>' . \S::get( 'text' ) . '</p>',
\S::get( 'email' )
) )
{
$mdb -> insert( 'pp_contact_emails', [
'email' => \S::get( 'email' ),
'phone' => \S::get('phone' ),
'title' => \S::get( 'subject' ),
'mail' => \S::get( 'text' ),
'add_date' => date("Y-m-d, H:i")
]);
$response = [ 'status' => 'ok' ];
}
}
echo json_encode( $response );
exit;
}
if ( \S::get( 'a' ) == 'cookie_close' )
{
setcookie( "cookie_information", "true", mktime( 0, 0, 0, 12, 31, 2115 ) );
exit;
}
if ( \S::get( 'a' ) == 'banner_close' )
{
\S::set_session( 'banner_close', true );
exit;
}
if ( \S::get( 'a' ) == 'contrast' )
{
\S::set_session( 'contrast', !\S::get_session( 'contrast' ) );
exit;
}
if ( \S::get( 'a' ) == 'article_unlock' )
{
\front\controls\Articles::article_unlock(
\S::get( 'password' ),
\S::get( 'article_id' )
);
exit;
}
if ( \S::get( 'a' ) == 'pixieset_gallery_download' ) {
$url = \front\controls\Articles::images_download( \S::get( 'hash' ) );
echo json_encode( [ 'url' => $url ] );
exit;
}
if ( \S::get( 'a' ) == 'pixieset_image_favorite' ) {
$status = \front\controls\Articles::pixieset_image_favorite( \S::get( 'image_id' ), \S::get( 'hash' ) );
echo json_encode( [ 'status' => $status ] );
exit;
}
if ( \S::get( 'a' ) == 'pixieset_save_favorite_images' ) {
$result = \front\controls\Articles::pixieset_save_favorite_images( \S::get( 'hash' ) );
echo json_encode( [ 'status' => $result ] );
exit;
}
if ( \S::get( 'a' ) == 'inline-edit-save' )
{
if ( strpos( \S::get( 'element_id' ), 'scontainer' ) !== false )
{
$scontainer_id = str_replace( [ 'scontainer-', '-content' ], [ '', '' ], \S::get( 'element_id' ) );
\Scontainer::updateByFrontEditor( $scontainer_id, \S::get( 'element_value' ), \S::get( 'lang_id' ) );
\S::delete_cache();
exit;
}
else
{
if ( \S::get( 'alltemplates' ) )
$layouts = $mdb -> select( 'pp_layouts', 'id' );
else
$layouts[] = \S::get( 'layout_id' );
foreach ( $layouts as $layout_id )
{
$layout = \front\factory\Layouts::layout_details( $layout_id );
$html = $layout['html'];
if ( strpos( $html, '[META_INDEX]' ) !== false )
{
$meta_index = true;
$html = str_replace( '[META_INDEX]', '', $html );
}
if ( strpos( $html, '[CSS]' ) !== false )
{
$css = true;
$html = str_replace( '[CSS]', '', $html );
}
if ( strpos( $html, '[JAVA_SCRIPT]' ) !== false )
{
$java_script = true;
$html = str_replace( '[JAVA_SCRIPT]', '', $html );
}
$html = preg_replace( '/^[ \t]*[\r\n]+/m', '', $html );
\S::suSetHtmlById( $html, \S::get( 'element_id' ), \S::get( 'element_value' ) );
if ( $meta_index )
$html = str_replace( '</head>', ' [META_INDEX]' . PHP_EOL . '</head>', $html );
if ( $css )
$html = str_replace( '</head>', ' [CSS]' . PHP_EOL . '</head>', $html );
if ( $java_script )
$html = str_replace( '</head>', ' [JAVA_SCRIPT]' . PHP_EOL . '</head>', $html );
$html = str_replace( [ '%5B', '%5D', '%20', '%24' ], [ '[', ']', ' ', '$' ], $html );
$mdb -> update( 'pp_layouts', [ 'html' => $html ], [ 'id' => $layout_id ] );
}
}
\S::delete_cache();
}
?>

View File

@@ -0,0 +1,71 @@
<?php
namespace admin;
class Site
{
public static function special_actions()
{
$sa = \S::get( 's-action' );
$domain = preg_replace( '#^(http(s)?://)?w{3}\.#', '$1', $_SERVER['SERVER_NAME'] );
$cookie_name = str_replace( '.', '-', $domain );
switch ( $sa )
{
case 'user-logon':
$result = \admin\factory\Users::logon( \S::get( 'login' ), \S::get( 'password' ) );
if ( $result == 1 )
{
if(\S::get('remember'))
{
$password = md5( \S::get( 'password' ) );
$login = \S::get( 'login' );
$value = [ login => $login , hash => $password ];
$value = json_encode( $value );
setcookie( $cookie_name, $value, time() +(86400 * 14), "/", $domain );
}
\S::set_session( 'user', \admin\factory\Users::details( \S::get( 'login' ) ) );
}
else
{
if ( $result == -1 )
\S::alert( 'Z powodu nieudanych 5 prób logowania Twoje konto zostało zablokowane.' );
else
\S::alert( 'Podane hasło jest nieprawidłowe, lub brak użytkownika o podanym loginie.' );
}
header( 'Location: /admin/articles/view_list/' );
exit;
break;
case 'user-logout':
setcookie( $cookie_name, "", time() -(86400), "/", $domain );
session_destroy();
header( 'Location: /admin/' );
exit;
break;
}
}
public static function route()
{
$_SESSION['admin'] = true;
$class = '\admin\controls\\';
$results = explode( '_', \S::get( 'module' ) );
if ( is_array( $results ) ) foreach ( $results as $row )
$class .= ucfirst( $row );
$action = \S::get( 'action' );
if ( class_exists( $class ) and method_exists( new $class, $action ) )
return call_user_func_array( array( $class, $action ), array() );
else
{
\S::alert( 'Nieprawidłowy adres url.' );
return false;
}
}
}

View File

@@ -0,0 +1,147 @@
<?php
namespace admin\controls;
class Articles
{
//autorzy artykułów
static public function articles_authors()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'article_administration', $user['id'] ) )
return \S::alert( 'Nie masz uprawnień' );
return \Tpl::view( 'articles/articles-authors' );
}
public static function duplicate_article()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'article_administration', $user['id'] ) )
return \S::alert( 'Nie masz uprawnień' );
if ( \admin\factory\Articles::duplicate_article( \S::get( 'id' ) ) )
\S::alert( 'Artykuł został zuplikowany' );
header( 'Location: /admin/articles/view_list/' );
exit;
}
public static function gallery_order_save()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'article_administration', $user['id'] ) )
{
echo json_encode( [ 'status' => 'error', 'msg' => 'Nie masz uprawnień' ] );
exit;
}
if ( \admin\factory\Articles::gallery_order_save( \S::get( 'article_id' ), \S::get( 'order' ) ) )
echo json_encode( [ 'status' => 'ok', 'msg' => 'Artykuł został zapisany.' ] );
exit;
}
static public function article_url_browser()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'article_administration', $user['id'] ) )
return \S::alert( 'Nie masz uprawnień' );
return \Tpl::view( 'articles/articles-browse-list', [
'modal' => true
] );
}
public static function browse_list()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'article_administration', $user['id'] ) )
return \S::alert( 'Nie masz uprawnień' );
return \admin\view\Articles::browse_list();
}
public static function article_delete()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'article_administration', $user['id'] ) )
return \S::alert( 'Nie masz uprawnień' );
if ( \admin\factory\Articles::articles_set_archive( \S::get( 'id' ) ) )
\S::alert( 'Artykuł został przeniesiony do archiwum.' );
header( 'Location: /admin/articles/view_list/' );
exit;
}
public static function article_save()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'article_administration',
$user['id'] ) )
return \S::alert( 'Nie masz uprawnień' );
$response = [ 'status' => 'error', 'msg' => 'Podczas zapisywania artykułu wystąpił błąd. Proszę spróbować ponownie.' ];
$values = \S::json_to_array( \S::get( 'values' ) );
if ( is_array( $values ) ) foreach ( $values as $key => $val )
{
if ( strpos( $key, 'ap_' ) !== false )
$params[$key] = $val;
}
$values['params'] = $params;
if ( $id = \admin\factory\Articles::article_save(
$values['id'], $values['title'], $values['main_image'], $values['entry'], $values['text'], $values['table_of_contents'], $values['status'], $values['show_title'], $values['show_date_add'], $values['date_add'],
$values['show_date_modify'], $values['seo_link'], $values['meta_title'], $values['meta_description'], $values['meta_keywords'], $values['layout_id'],
$values['pages'], $values['noindex'], $values['repeat_entry'], $values['copy_from'], $values['social_icons'], $values['event_date'], $values['hidden-tags'], $values['block_direct_access'],
$values['priority'], $values['password'], $values['pixieset'], $values['id_author'], $params
) )
$response = [ 'status' => 'ok', 'msg' => 'Artykuł został zapisany.', 'id' => $id ];
\admin\factory\Articles::insert_missing_hash();
echo json_encode( $response );
exit;
}
public static function article_edit()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'article_administration',
$user['id'] ) )
return \S::alert( 'Nie masz uprawnień' );
\admin\factory\Articles::delete_nonassigned_images();
\admin\factory\Articles::delete_nonassigned_files();
return \admin\view\Articles::article_edit( [
'article' => \admin\factory\Articles::article_details( \S::get( 'id' ) ),
'menus' => \admin\factory\Pages::menus_list(),
'languages' => \admin\factory\Languages::languages_list(),
'layouts' => \admin\factory\Layouts::layouts_list(),
'additional_params_lon' => \admin\factory\Articles::additional_params( 1 ),
'additional_params_loff' => \admin\factory\Articles::additional_params( 0 ),
'settings' => \admin\factory\Settings::settings_details(),
'authors' => \admin\factory\Authors::get_simple_list()
] );
}
public static function view_list()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'article_administration', $user['id'] ) )
return \S::alert( 'Brak uprawnień.' );
return \admin\view\Articles::articles_list();
}
}
?>

View File

@@ -0,0 +1,44 @@
<?php
namespace admin\controls;
class ArticlesArchive
{
public static function article_restore()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'article_administration',
$user['id'] ) )
return \S::alert( 'Nie masz uprawnień' );
if ( \admin\factory\ArticlesArchive::article_restore( \S::get( 'id' ) ) )
\S::alert( 'Artykuł został przywrócony.' );
header( 'Location: /admin/articles_archive/view_list/' );
exit;
}
public static function article_delete()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'article_administration',
$user['id'] ) )
return \S::alert( 'Nie masz uprawnień' );
if ( \admin\factory\ArticlesArchive::article_delete( \S::get( 'id' ) ) )
\S::alert( 'Artykuł został usunięty.' );
header( 'Location: /admin/articles_archive/view_list/' );
exit;
}
public static function view_list()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'article_administration',
$user['id'] ) )
return \S::alert( 'Nie masz uprawnień' );
return \admin\view\ArticlesArchive::articles_list();
}
}

View File

@@ -0,0 +1,65 @@
<?
namespace admin\controls;
class Authors
{
// usunięcie autora
static public function delete()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'article_administration', $user['id'] ) )
return \S::alert( 'Nie masz uprawnień' );
$response = [ 'status' => 'error', 'msg' => 'Podczas usuwania autora wystąpił błąd. Proszę spróbować ponownie.' ];
$values = \S::json_to_array( \S::get( 'values' ) );
if ( \admin\factory\Authors::delete_author( \S::get( 'id' ) ) )
\S::alert( 'Autor został usunięty.' );
header( 'Location: /admin/authors/view_list/' );
exit;
}
// zapis autora
static public function save()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'article_administration', $user['id'] ) )
return \S::alert( 'Nie masz uprawnień' );
$response = [ 'status' => 'error', 'msg' => 'Podczas zapisywania autora wystąpił błąd. Proszę spróbować ponownie.' ];
$values = \S::json_to_array( \S::get( 'values' ) );
if ( $author_id = \admin\factory\Authors::save_author( $values['id'], $values['author'], $values['image'], $values['description'] ) )
$response = [ 'status' => 'ok', 'msg' => 'Autor został zapisany.', 'id' => $author_id ];
echo json_encode( $response );
exit;
}
// edycja autora
static public function edit()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'article_administration', $user['id'] ) )
return \S::alert( 'Nie masz uprawnień' );
return \Tpl::view( 'authors/author-edit', [
'author' => \admin\factory\Authors::get_single_author( \S::get( 'id' ) ),
'languages' => \admin\factory\Languages::languages_list()
] );
}
//autorzy artykułów
static public function view_list()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'article_administration', $user['id'] ) )
return \S::alert( 'Nie masz uprawnień' );
return \Tpl::view( 'authors/view-list' );
}
}

View File

@@ -0,0 +1,66 @@
<?php
namespace admin\controls;
class Backups
{
public static function download_restore_file()
{
$file = '../restore.php';
if ( file_exists( $file ) )
{
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.basename($file).'"');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize( $file ) );
readfile( $file );
exit;
}
}
public static function view_list()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'backups_administration', $user['id'] ) )
return \S::alert( 'Nie masz uprawnień' );
return \admin\view\Backups::backups_list(
\admin\factory\Backups::backups_list()
);
}
public static function backup_save()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'backups_administration', $user['id'] ) )
return \S::alert( 'Nie masz uprawnień' );
$response = 'Podczas tworzenia kopi zapasowej wystąpił błąd. Proszę spróbować ponownie.';
if ( \admin\factory\Backups::backup_save() )
\S::alert( 'Kopia zapasowa został utworzona.' );
header( 'Location: /admin/backups/view_list/' );
exit;
}
public static function backup_delete()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'backups_administration', $user['id'] ) )
return \S::alert( 'Nie masz uprawnień' );
$response = 'Podczas usuwania kopi zapasowej wystąpił błąd. Proszę spróbować ponownie.';
if ( \admin\factory\Backups::backup_delete( \S::get( 'name' ) ) )
\S::alert( 'Kopia zapasowa został usunięta.' );
header( 'Location: /admin/backups/view_list/' );
exit;
}
}

View File

@@ -0,0 +1,66 @@
<?php
namespace admin\controls;
class Banners
{
public static function banner_delete()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'baners_administration',
$user['id'] ) )
return \S::alert( 'Nie masz uprawnień' );
if ( \admin\factory\Banners::banner_delete( \S::get( 'id' ) ) )
\S::alert( 'Baner został usunięty.' );
header( 'Location: /admin/banners/view_list/' );
exit;
}
public static function banner_save()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'baners_administration',
$user['id'] ) )
return \S::alert( 'Nie masz uprawnień' );
$response = [ 'status' => 'error', 'msg' => 'Podczas zapisywania baneru wystąpił błąd. Proszę spróbować ponownie.' ];
$values = \S::json_to_array( \S::get( 'values' ) );
if ( $banner_id = \admin\factory\Banners::banner_save( $values['id'], $values['name'], $values['status'], $values['date_start'], $values['date_end'],
$values['home_page'], $values['src'], $values['url'], $values['html'], $values['text'] ) )
$response = [ 'status' => 'ok', 'msg' => 'Baner został zapisany.', 'id' => $banner_id ];
echo json_encode( $response );
exit;
}
public static function banner_edit()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'baners_administration', $user['id'] ) )
return \S::alert( 'Nie masz uprawnień' );
return \admin\view\Banners::banner_edit(
\admin\factory\Banners::banner_details(
\S::get( 'id' )
),
\admin\factory\Languages::languages_list()
);
}
public static function view_list()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'baners_administration', $user['id'] ) )
return \S::alert( 'Nie masz uprawnień' );
return \admin\view\Banners::banners_list();
}
}
?>

View File

@@ -0,0 +1,28 @@
<?php
namespace admin\controls;
class Emails{
public static function view_list()
{
global $user;
if( !\admin\factory\Users::check_privileges( 'emails_administration', $user['id']))
return \S::alert('Nie masz uprawnień');
return \admin\view\Emails::emails_list();
}
public static function email_details()
{
global $user;
if( !\admin\factory\Users::check_privileges( 'emails_administration', $user['id']))
return \S::alert('Nie masz uprawnień');
return \admin\view\Emails::email_details(
\admin\factory\Emails::email_details(
\S::get( 'id' )
)
);
}
}

View File

@@ -0,0 +1,15 @@
<?php
namespace admin\controls;
class Filemanager
{
public function draw()
{
global $user;
if( !\admin\factory\Users::check_privileges( 'fileManager_administration', $user['id']))
return \S::alert('Nie masz uprawnień');
return \admin\view\FileManager::filemanager();
}
}
?>

View File

@@ -0,0 +1,126 @@
<?
namespace admin\controls;
class Languages
{
public static function language_delete()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'language_administration', $user['id'] ) )
return \S::alert( 'Nie masz uprawnień' );
if ( \admin\factory\Languages::language_delete( \S::get( 'id' ) ) )
\S::alert( 'Język został usunięty.' );
header( 'Location: /admin/languages/view_list/' );
exit;
}
public static function language_save()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'language_administration', $user['id'] ) )
return \S::alert( 'Nie masz uprawnień' );
$response = [ 'status' => 'error', 'msg' => 'Podczas zapisywania języka wystąpił błąd. Proszę spróbować ponownie.' ];
$values = \S::json_to_array( \S::get( 'values' ) );
if ( \admin\factory\Languages::language_save(
$values['id'], $values['name'], $values['status'], $values['start'], $values['o'], $values['domain'], $values['main_domain']
) )
$response = [ 'status' => 'ok', 'msg' => 'Język został zapisany.', 'id' => $id ];
echo json_encode( $response );
exit;
}
public static function language_edit()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'language_administration', $user['id'] ) )
return \S::alert( 'Nie masz uprawnień' );
return \admin\view\Languages::language_edit(
\admin\factory\Languages::language_details(
\S::get( 'id' )
), \admin\factory\Languages::max_order()
);
}
public static function view_list()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'language_administration', $user['id'] ) )
return \S::alert( 'Nie masz uprawnień' );
return \admin\view\Languages::languages_list();
}
public static function translation_delete()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'language_administration', $user['id'] ) )
return \S::alert( 'Nie masz uprawnień' );
if ( \admin\factory\Languages::translation_delete( \S::get( 'id' ) ) )
\S::alert( 'Tłumaczenie zostało usunięte.' );
header( 'Location: /admin/languages/translation_list/' );
exit;
}
public static function translation_save()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'language_administration', $user['id'] ) )
return \S::alert( 'Nie masz uprawnień' );
$response = [ 'status' => 'error', 'msg' => 'Podczas zapisywania tłumaczenia wystąpił błąd. Proszę spróbować ponownie.' ];
$values = \S::json_to_array( \S::get( 'values' ) );
$languages_list = \admin\factory\Languages::languages_list();
if ( is_array( $languages_list ) and !empty( $languages_list ) ) foreach ( $languages_list as $language )
{
\S::delete_session( 'lang-' . $language['id'] );
$languages[ $language['id'] ] = $values[ $language['id'] ];
}
if ( $id = \admin\factory\Languages::translation_save( $values['id'], $values['text'], $languages ) )
$response = [ 'status' => 'ok', 'msg' => 'Tłumaczenie zostało zapisane.', 'id' => $id ];
echo json_encode( $response );
exit;
}
public static function translation_edit()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'language_administration', $user['id'] ) )
return \S::alert( 'Nie masz uprawnień' );
return \admin\view\Languages::translation_edit(
\admin\factory\Languages::translation_details( \S::get( 'id' ) ),
\admin\factory\Languages::languages_list()
);
}
public static function translation_list()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'language_administration',
$user['id'] ) )
return \S::alert( 'Nie masz uprawnień' );
return \admin\view\Languages::translations_list();
}
}
?>

View File

@@ -0,0 +1,59 @@
<?php
namespace admin\controls;
class Layouts
{
public static function layout_delete()
{
global $user;
if( !\admin\factory\Users::check_privileges( 'template_administration', $user['id']))
return \S::alert('Nie masz uprawnień');
if ( \admin\factory\Layouts::layout_delete( \S::get( 'id' ) ) )
\S::alert( 'Szablon został usunięty.' );
header( 'Location: /admin/layouts/view_list/' );
exit;
}
public static function layout_save()
{
global $user;
if( !\admin\factory\Users::check_privileges( 'template_administration', $user['id']))
return \S::alert('Nie masz uprawnień');
$response = [ 'status' => 'error', 'msg' => 'Podczas zapisywania szablonu wystąpił błąd. Proszę spróbować ponownie.' ];
$values = \S::json_to_array( \S::get( 'values' ) );
if ( $id = \admin\factory\Layouts::layout_save( $values['id'], $values['name'], $values['status'], $values['pages'], $values['html'], $values['css'], $values['js'], $values['m_html'], $values['m_css'], $values['m_js'] ) )
$response = [ 'status' => 'ok', 'msg' => 'Szablon został zapisany.', 'id' => $id ];
echo json_encode( $response );
exit;
}
public static function layout_edit()
{
global $user;
if( !\admin\factory\Users::check_privileges( 'template_administration', $user['id']))
return \S::alert('Nie masz uprawnień');
return \admin\view\Layouts::layout_edit(
\admin\factory\Layouts::layout_details(
\S::get( 'id' )
),
\admin\factory\Layouts::menus_list()
);
}
public static function view_list()
{
global $user;
if( !\admin\factory\Users::check_privileges( 'template_administration', $user['id']))
return \S::alert('Nie masz uprawnień');
return \admin\view\Layouts::layouts_list();
}
}
?>

View File

@@ -0,0 +1,167 @@
<?php
namespace admin\controls;
class Newsletter
{
public static function emails_import()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'newsletter_administration', $user['id'] ) )
return \S::alert( 'Nie masz uprawnień' );
$values = \S::json_to_array( \S::get( 'values' ) );
if ( \admin\factory\Newsletter::emails_import( $values['emails'] ) )
\S::alert( 'Emaile zostały zaimportowane.' );
echo json_encode( [ 'status' => 'ok', 'msg' => 'Emaile zostały zaimportowane.' ] );
exit;
}
public static function import()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'newsletter_administration', $user['id'] ) )
return \S::alert( 'Nie masz uprawnień' );
return \Tpl::view( 'newsletter/import' );
}
public static function emails_list()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'newsletter_administration', $user['id'] ) )
return \S::alert('Nie masz uprawnień');
return \admin\view\Newsletter::emails_list();
}
public static function send()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'newsletter_administration', $user['id'] ) )
return \S::alert( 'Nie masz uprawnień' );
if ( \admin\factory\Newsletter::send( \S::get( 'dates' ), \S::get( 'template' ), \S::get( 'only_once' ) ) )
\S::alert( 'Newsletter został dodany do kolejki wysyłania.' );
header( 'Location: /admin/newsletter/prepare/' );
exit;
}
public static function prepare()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'newsletter_administration', $user['id'] ) )
return \S::alert('Nie masz uprawnień');
return \admin\view\Newsletter::prepare(
\admin\factory\Newsletter::templates_list()
);
}
public static function settings_save()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'newsletter_administration', $user['id'] ) )
return \S::alert( 'Nie masz uprawnień' );
$values = \S::json_to_array( \S::get( 'values' ) );
\admin\factory\Settings::settings_update( 'newsletter_footer_1', $values['newsletter_footer_1'] );
\admin\factory\Settings::settings_update( 'newsletter_footer_2', $values['newsletter_footer_2'] );
\admin\factory\Settings::settings_update( 'newsletter_header', $values['newsletter_header'] );
\S::alert( 'Ustawienia zostały zapisane.' );
echo json_encode( [ 'status' => 'ok', 'msg' => 'Ustawienia zostały zapisane.' ] );
exit;
}
public static function settings()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'newsletter_administration', $user['id']))
return \S::alert('Nie masz uprawnień');
return \admin\view\Newsletter::settings(
\admin\factory\Settings::settings_details()
);
}
public static function email_templates_user()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'newsletter_administration', $user['id'] ) )
return \S::alert('Nie masz uprawnień');
return \admin\view\Newsletter::email_templates_user();
}
public static function email_templates_admin()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'newsletter_administration', $user['id'] ) )
return \S::alert('Nie masz uprawnień');
return \admin\view\Newsletter::email_templates_admin();
}
public static function email_template_delete()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'newsletter_administration', $user['id'] ) )
return \S::alert( 'Nie masz uprawnień' );
$is_admin = \admin\factory\Newsletter::is_admin_template( \S::get( 'id' ) );
if ( !$is_admin and \admin\factory\Newsletter::newsletter_template_delete( \S::get( 'id' ) ) )
\S::alert( 'Szablon newslettera został usunięty.' );
if ( $is_admin )
header( 'Location: /admin/newsletter/email_templates_admin/' );
else
header( 'Location: /admin/newsletter/email_templates_user/' );
exit;
}
public static function email_template_edit()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'newsletter_administration', $user['id']))
return \S::alert('Nie masz uprawnień');
return \admin\view\Newsletter::email_template_edit(
\admin\factory\Newsletter::email_template_detalis(
\S::get( 'id' )
)
);
}
public static function template_save()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'newsletter_administration', $user['id']))
return \S::alert('Nie masz uprawnień');
$response = [ 'status' => 'error', 'msg' => 'Podczas zapisywania wystąpił błąd. Proszę spróbować ponownie.' ];
$values = \S::json_to_array( \S::get( 'values' ) );
if ( $id = \admin\factory\Newsletter::template_save( $values['id'], $values['name'], $values['text'] ) )
$response = [ 'status' => 'ok', 'msg' => 'Zmiany zostały zapisane.', 'id' => $id ];
echo json_encode( $response );
exit;
}
}

View File

@@ -0,0 +1,155 @@
<?php
namespace admin\controls;
class Pages
{
static public function pages_url_browser()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'page_administration', $user['id'] ) )
return \S::alert( 'Nie masz uprawnień' );
return \Tpl::view( 'pages/pages-browse-list', [
'menus' => \admin\factory\Pages::menus_list(),
'modal' => true
] );
}
static public function browse_list()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'page_administration', $user['id'] ) )
return \S::alert( 'Nie masz uprawnień' );
return \admin\view\Pages::browse_list(
\admin\factory\Pages::menus_list()
);
}
public static function menu_delete()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'page_administration',
$user['id'] ) )
return \S::alert( 'Nie masz uprawnień' );
if ( \admin\factory\Pages::menu_delete( \S::get( 'id' ) ) )
\S::set_message( 'Menu zostało usunięte.' );
else
\S::alert( 'Podczas usuwania menu wystąpił błąd. Aby usunąć menu nie może ono posiadać przypiętych stron.' );
header( 'Location: /admin/pages/view_list/' );
exit;
}
public static function page_delete()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'page_administration',
$user['id'] ) )
return \S::alert( 'Nie masz uprawnień' );
if ( \admin\factory\Pages::page_delete( \S::get( 'id' ) ) )
\S::set_message( 'Strona została usunięta.' );
else
\S::alert( 'Podczas usuwania strony wystąpił błąd. Aby usunąć stronę nie może ona posiadać przypiętych podstron.' );
header( 'Location: /admin/pages/view_list/' );
exit;
}
public static function page_articles()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'page_administration',
$user['id'] ) )
return \S::alert( 'Nie masz uprawnień' );
return \admin\view\Pages::page_articles( \S::get( 'id' ),
\admin\factory\Pages::page_articles( \S::get( 'id' ) ) );
}
public static function page_save()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'page_administration',
$user['id'] ) )
return \S::alert( 'Nie masz uprawnień' );
$response = [ 'status' => 'error', 'msg' => 'Podczas zapisywania strony wystąpił błąd. Proszę spróbować ponownie.' ];
$values = \S::json_to_array( \S::get( 'values' ) );
if ( $id = \admin\factory\Pages::page_save(
$values['id'], $values['title'], $values['seo_link'], $values['meta_title'], $values['meta_description'], $values['meta_keywords'], $values['menu_id'],
$values['parent_id'], $values['page_type'], $values['sort_type'], $values['layout_id'], $values['articles_limit'], $values['show_title'],
$values['status'], $values['link'], $values['noindex'], $values['start'], $values['site_title'], $values['block_direct_access'], $values['cache'], $values['canonical']
) )
$response = [ 'status' => 'ok', 'msg' => 'Strona została zapisana.', 'id' => $id ];
echo json_encode( $response );
exit;
}
public static function page_edit()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'page_administration',
$user['id'] ) )
return \S::alert( 'Nie masz uprawnień' );
return \admin\view\Pages::page_edit(
\admin\factory\Pages::page_details(
\S::get( 'id' )
), \S::get( 'pid' ), \S::get( 'menu_id' ),
\admin\factory\Pages::menu_lists(),
\admin\factory\Layouts::layouts_list(),
\admin\factory\Languages::languages_list(),
\admin\factory\Settings::settings_details()
);
}
public static function menu_save()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'page_administration',
$user['id'] ) )
return \S::alert( 'Nie masz uprawnień' );
$response = [ 'status' => 'error', 'msg' => 'Podczas zapisywania menu wystąpił błąd. Proszę spróbować ponownie.' ];
$values = \S::json_to_array( \S::get( 'values' ) );
if ( \admin\factory\Pages::menu_save( $values['id'], $values['name'],
$values['status'] ) )
$response = [ 'status' => 'ok', 'msg' => 'Menu zostało zapisane.' ];
echo json_encode( $response );
exit;
}
public static function menu_edit()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'page_administration',
$user['id'] ) )
return \S::alert( 'Nie masz uprawnień' );
return \admin\view\Pages::menu_edit(
\admin\factory\Pages::menu_details( \S::get( 'id' ) )
);
}
public static function view_list()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'page_administration',
$user['id'] ) )
return \S::alert( 'Nie masz uprawnień' );
return \admin\view\Pages::pages_list(
\admin\factory\Pages::menus_list()
);
}
}
?>

View File

@@ -0,0 +1,75 @@
<?php
namespace admin\controls;
class Scontainers
{
static public function ckeditor_list()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'scontainers_administration', $user['id'] ) )
return \S::alert( 'Nie masz uprawnień' );
return \Tpl::view( '/scontainers/ckeditor-list' );
}
public static function container_delete()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'scontainers_administration',
$user['id'] ) )
return \S::alert( 'Nie masz uprawnień' );
if ( \admin\factory\Scontainers::container_delete( \S::get( 'id' ) ) )
\S::alert( 'Kontener został usunięty.' );
header( 'Location: /admin/scontainers/view_list/' );
exit;
}
public static function container_save()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'scontainers_administration',
$user['id'] ) )
return \S::alert( 'Nie masz uprawnień' );
$response = [ 'status' => 'error', 'msg' => 'Podczas zapisywania kontenera wystąpił błąd. Proszę spróbować ponownie.' ];
$values = \S::json_to_array( \S::get( 'values' ) );
if ( $id = \admin\factory\Scontainers::container_save( $values['id'], $values['title'], $values['text'], $values['status'], $values['show_title'],
$values['src'], $values['html']
) )
$response = [ 'status' => 'ok', 'msg' => 'Kontener został zapisany.', 'id' => $id ];
echo json_encode( $response );
exit;
}
public static function container_edit()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'scontainers_administration',
$user['id'] ) )
return \S::alert( 'Nie masz uprawnień' );
return \admin\view\Scontainers::container_edit(
\admin\factory\Scontainers::container_details(
\S::get( 'id' )
), \admin\factory\Languages::languages_list()
);
}
public static function view_list()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'scontainers_administration',
$user['id'] ) )
return \S::alert( 'Nie masz uprawnień' );
return \admin\view\Scontainers::containers_list();
}
}

View File

@@ -0,0 +1,59 @@
<?php
namespace admin\controls;
class SeoAdditional
{
public static function element_delete()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'seo_administration', $user['id'] ) )
return \S::alert( 'Nie masz uprawnień' );
if ( \admin\factory\SeoAdditional::element_delete( \S::get( 'id' ) ) )
\S::alert( 'Element został usunięty.' );
header( 'Location: /admin/seo_additional/main_view/' );
exit;
}
public static function element_save()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'seo_administration', $user['id']))
return \S::alert( 'Nie masz uprawnień' );
$response = [ 'status' => 'error', 'msg' => 'Podczas zapisywania elementu wystąpił błąd. Proszę spróbować ponownie.' ];
$values = \S::json_to_array( \S::get( 'values' ) );
if ( $id = \admin\factory\SeoAdditional::element_save( $values['id'], $values['url'], $values['status'], $values['title'], $values['keywords'], $values['description'], $values['text'] ) )
$response = [ 'status' => 'ok', 'msg' => 'Zmiany zostały zapisane.', 'id' => $id ];
echo json_encode( $response );
exit;
}
public static function element_edit()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'seo_administration', $user['id']))
return \S::alert( 'Nie masz uprawnień' );
return \admin\view\SeoAdditional::element_edit(
\admin\factory\SeoAdditional::element_details(
\S::get( 'id' )
)
);
}
public static function main_view()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'seo_administration', $user['id'] ) )
return \S::alert( 'Nie masz uprawnień' );
return \admin\view\SeoAdditional::main_view();
}
}

View File

@@ -0,0 +1,79 @@
<?
namespace admin\controls;
class Settings
{
public static function settings_save()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'settings_administration', $user['id'] ) )
return \S::alert('Nie masz uprawnień');
$settings = \admin\factory\Settings::settings_details();
$values = \S::json_to_array( \S::get( 'values' ) );
\admin\factory\Settings::settings_save(
$values['firm_name'],
$values['firm_adress'],
$values['additional_info'],
$values['contact_form'] == 'on' ? 1 : 0,
$values['contact_email'],
$values['email_host'],
$values['email_port'],
$values['email_login'],
$values['email_password'],
$values['google_maps'],
$values['facebook_link'],
$values['statistic_code'],
$values['htaccess'],
$values['robots'],
$settings['newsletter_header'],
$settings['newsletter_footer_1'],
$settings['newsletter_footer_2'],
$values['google_map_key'],
$values['google_search_console'],
$values['update'],
$values['devel'],
$values['news_limit'],
$values['visit_counter'],
$values['calendar'],
$values['tags'],
$values['ssl'],
$values['mysql_debug'],
$values['htaccess_cache'],
$settings['visits'],
$values['links_structure'],
$values['link_version'],
$values['widget_phone'],
$values['update_key']
);
\admin\factory\Settings::settings_update( 'image_px', $values['image_px'] );
\admin\factory\Settings::settings_update( 'newsletter_cron', $values['newsletter_cron'] );
\admin\factory\Settings::settings_update( 'lazy_loading', $values['lazy_loading'] == 'on' ? 1 : 0 );
\admin\factory\Settings::settings_update( 'generate_webp', $values['generate_webp'] == 'on' ? 1 : 0 );
\admin\factory\Settings::settings_update( 'contact_form_captcha', $values['contact_form_captcha'] == 'on' ? 1 : 0 );
\admin\factory\Settings::settings_update( 'url_version', $values['url_version'] );
\S::delete_cache();
\S::htacces();
\S::alert( 'Ustawienia zostały zapisane.' );
echo json_encode( [ 'status' => 'ok', 'msg' => 'Ustawienia zostały zapisane.' ] );
exit;
}
public static function view()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'settings_administration', $user['id']))
return \S::alert('Nie masz uprawnień');
return \admin\view\Settings::view(
\admin\factory\Settings::settings_details()
);
}
}
?>

View File

@@ -0,0 +1,29 @@
<?php
namespace admin\controls;
class Update
{
public static function update()
{
if ( !\admin\factory\Update::update() )
\S::alert( 'W trakcie aktualizacji systemu wystąpił błąd. Proszę spróbować ponownie.' );
else
\S::set_message( 'Aktualizacja przebiegła pomyślnie.' );
header( 'Location: /admin/update/main_view/' );
exit;
}
public static function updateAll()
{
$response['status'] = \admin\factory\Update::update();
$response['version'] = number_format( \S::get('version_current') + 0.001, 3, '.', '' );
echo json_encode( $response );
exit;
}
public static function main_view()
{
return \admin\view\Update::main_view();
}
}

View File

@@ -0,0 +1,59 @@
<?php
namespace admin\controls;
class Users
{
public static function user_delete()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'users_administration', $user['id'] ) )
return \S::alert('Nie masz uprawnień');
if ( \admin\factory\Users::user_delete( \S::get( 'id' ) ) )
\S::alert( 'Użytkownik został usunięty.' );
header( 'Location: /admin/users/view_list/' );
exit;
}
public static function user_save()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'users_administration', $user['id'] ) )
return \S::alert('Nie masz uprawnień');
$values = \S::json_to_array( \S::get( 'values' ) );
$response = \admin\factory\Users::user_save(
$values['id'], $values['login'], $values['status'], $values['active_to'], $values['password'], $values['password_re'], $values['admin'], $values['privileges']
);
echo json_encode( $response );
exit;
}
public static function user_edit()
{
global $user;
if ( !\admin\factory\Users::check_privileges( 'users_administration', $user['id'] ) )
return \S::alert('Nie masz uprawnień');
return \admin\view\Users::user_edit(
\admin\factory\Users::user_details(
\S::get( 'id' ) ),
\admin\factory\Users::user_privileges(
\S::get( 'id' ) )
);
}
public static function view_list()
{
global $user;
if( !\admin\factory\Users::check_privileges( 'users_administration', $user['id']))
return \S::alert('Nie masz uprawnień');
return \admin\view\Users::users_list();
}
}
?>

View File

@@ -0,0 +1,693 @@
<?php
namespace admin\factory;
class Articles
{
public static function duplicate_article( $article_id )
{
global $mdb, $user;
$article = \admin\factory\Articles::article_details( $article_id );
if ( $article )
{
$mdb -> insert( 'pp_articles', [
'show_title' => $article['show_title'],
'show_date_add' => $article['show_date_add'],
'show_date_modify' => $article['show_date_modify'],
'date_add' => date( 'Y-m-d H:i:s' ),
'date_modify' => date( 'Y-m-d H:i:s' ),
'modify_by' => $user['id'],
'layout_id' => $article['layout_id'],
'status' => $article['status'],
'repeat_entry' => $article['repeat_entry'],
'social_icons' => $article['social_icons'],
'date_start' => $article['date_start'],
'date_end' => $article['event_date'],
'priority' => $article['priority'],
'password' => $article['password'],
'pixieset' => $article['pixieset']
] );
$article_tmp_id = $mdb -> id();
if ( $article_tmp_id )
{
foreach ( $article['languages'] as $key => $val )
{
$mdb -> insert( 'pp_articles_langs', [
'article_id' => $article_tmp_id,
'lang_id' => $key,
'title' => 'Kopia: ' . $val['title'],
'entry' => $val['entry'],
'text' => $val['text'],
'meta_title' => null,
'meta_description' => null,
'meta_keywords' => null,
'seo_link' => null,
'copy_from' => $val['copy_from'],
'block_direct_access' => $val['block_direct_access']
] );
}
foreach ( $article['params'] as $param )
{
$mdb -> insert( 'pp_articles_additional_values', [
'param_id' => $param['param_id'],
'value' => $param['value'],
'article_id' => $article_tmp_id,
'language_id' => $param['language_id']
] );
}
foreach ( $article['pages'] as $page )
{
$order = self::max_order() + 1;
$mdb -> insert( 'pp_articles_pages', [
'article_id' => $article_tmp_id,
'page_id' => $page,
'o' => (int)$order
] );
}
return true;
}
}
return false;
}
public static function insert_missing_hash() {
global $mdb;
if ( $mdb -> count( 'pp_articles', [ 'hash' => null ] ) ) {
$rows = $mdb -> select( 'pp_articles', [ 'id', 'date_add' ], [ 'hash' => null ] );
if ( is_array( $rows ) ) foreach ( $rows as $row ) {
$mdb -> update( 'pp_articles', [ 'hash' => md5( $row['id'] . $row['date_add'] ) ], [ 'id' => $row['id'] ] );
}
}
return true;
}
public static function gallery_order_save( $article_id, $order )
{
global $mdb;
$order = explode( ';', $order );
if ( is_array( $order ) and !empty( $order ) ) foreach ( $order as $image_id )
{
$mdb -> update( 'pp_articles_images', [
'o' => $i++
], [
'AND' => [
'article_id' => $article_id,
'id' => $image_id
]
] );
}
}
public static function additional_params( $language = 0 )
{
global $mdb;
return $mdb -> select( 'pp_articles_additional_params', '*', [ 'AND' => [ 'status' => 1, 'language' => $language ] ] );
}
public static function image_alt_change( $image_id, $image_alt )
{
global $mdb;
$result = $mdb -> update( 'pp_articles_images', [
'alt' => $image_alt
], [
'id' => $image_id
] );
\S::delete_cache();
return $result;
}
public static function articles_by_date_add( $date_start, $date_end )
{
global $mdb;
$results = $mdb -> query( 'SELECT '
. 'id '
. 'FROM '
. 'pp_articles '
. 'WHERE '
. 'status = 1 '
. 'AND '
. 'date_add BETWEEN \'' . $date_start . '\' AND \'' . $date_end . '\' '
. 'ORDER BY '
. 'date_add DESC' ) -> fetchAll();
if ( is_array( $results ) and !empty( $results ) ) foreach ( $results as $row )
$articles[] = \front\factory\Articles::article_details( $row['id'], 'pl' );
return $articles;
}
public static function article_url( $article_id )
{
global $mdb;
$results = $mdb -> query( "SELECT seo_link FROM pp_articles_langs AS pal, pp_langs AS pl WHERE lang_id = pl.id AND article_id = " . (int)$article_id . " AND seo_link != '' ORDER BY o ASC LIMIT 1" ) -> fetchAll();
if ( !$results[0]['seo_link'] )
{
$title = self::article_title( $article_id );
return 'a-' . $article_id . '-' . \S::seo( $title );
}
else
return $results[0]['seo_link'];
}
public static function article_pages( $article_id )
{
global $mdb;
$results = $mdb -> query( "SELECT page_id FROM pp_articles_pages WHERE article_id = " . (int)$article_id ) -> fetchAll();
if ( is_array( $results ) and !empty( $results ) ) foreach ( $results as $row )
{
if ( $out == '' )
$out .= ' - ';
$out .= \admin\factory\Pages::page_title( $row['page_id'] );
if ( end( $results ) != $row )
$out .= ' / ';
}
return $out;
}
public static function article_title( $article_id )
{
global $mdb;
$results = $mdb -> query( "SELECT title FROM pp_articles_langs AS pal, pp_langs AS pl WHERE lang_id = pl.id AND article_id = " . (int)$article_id . " AND title != '' ORDER BY o ASC LIMIT 1" ) -> fetchAll();
return $results[0]['title'];
}
public static function articles_set_archive( $article_id )
{
global $mdb;
$result = $mdb -> update( 'pp_articles', [ 'status' => -1 ], [ 'id' => (int)$article_id ] );
\S::htacces();
\S::delete_cache();
return $result;
}
public static function file_name_change( $file_id, $file_name )
{
global $mdb;
$mdb -> update( 'pp_articles_files', [ 'name' => $file_name ], [ 'id' => (int)$file_id ] );
return true;
}
public static function delete_file( $file_id )
{
global $mdb;
$mdb -> update( 'pp_articles_files', [ 'to_delete' => 1 ], [ 'id' => (int)$file_id ] );
return true;
}
public static function delete_img( $image_id )
{
global $mdb;
$mdb -> update( 'pp_articles_images', [ 'to_delete' => 1 ], [ 'id' => (int)$image_id ] );
return true;
}
public static function article_details( $article_id )
{
global $mdb;
if ( $article = $mdb -> get( 'pp_articles', '*', [ 'id' => (int)$article_id ] ) )
{
$results = $mdb -> select( 'pp_articles_langs', '*', [ 'article_id' => (int)$article_id ] );
if ( is_array( $results ) ) foreach ( $results as $row )
$article['languages'][ $row['lang_id'] ] = $row;
$article['images'] = $mdb -> select( 'pp_articles_images', '*', [ 'article_id' => (int)$article_id, 'ORDER' => [ 'o' => 'ASC', 'id' => 'ASC' ] ] );
$article['files'] = $mdb -> select( 'pp_articles_files', '*', [ 'article_id' => (int)$article_id ] );
$article['pages'] = $mdb -> select( 'pp_articles_pages', 'page_id', [ 'article_id' => (int)$article_id ] );
$article['tags'] = $mdb -> select( 'pp_tags', [ '[><]pp_articles_tags' => [ 'id' => 'tag_id' ] ], 'name', [ 'article_id' => (int)$article_id ] );
$article['params'] = $mdb -> select( 'pp_articles_additional_values', [ 'param_id', 'value', 'language_id' ], [ 'article_id' => (int)$article_id ] );
}
return $article;
}
public static function max_order()
{
global $mdb;
return $mdb -> max( 'pp_articles_pages', 'o' );
}
public static function article_save(
$article_id, $title, $main_image, $entry, $text, $table_of_contents, $status, $show_title, $show_date_add, $date_add, $show_date_modify, $seo_link, $meta_title, $meta_description,
$meta_keywords, $layout_id, $pages, $noindex, $repeat_entry, $copy_from, $social_icons, $event_date, $tags, $block_direct_access, $priority,
$password, $pixieset, $id_author, $params )
{
global $mdb, $user;
$event_date = explode( ' - ', $event_date );
if ( !$article_id )
{
$mdb -> insert( 'pp_articles', [
'show_title' => $show_title == 'on' ? 1 : 0,
'show_date_add' => $show_date_add == 'on' ? 1 : 0,
'show_date_modify' => $show_date_modify == 'on' ? 1 : 0,
'date_add' => $date_add ? $date_add : date( 'Y-m-d H:i:s' ),
'date_modify' => $date_add ? $date_add : date( 'Y-m-d H:i:s' ),
'modify_by' => $user['id'],
'layout_id' => $layout_id ? (int)$layout_id : null,
'status' => $status == 'on' ? 1 : 0,
'repeat_entry' => $repeat_entry == 'on' ? 1 : 0,
'social_icons' => $social_icons == 'on' ? 1 : 0,
'date_start' => $event_date[0] ? $event_date[0] : null,
'date_end' => $event_date[1] ? $event_date[1] : null,
'priority' => $priority == 'on' ? 1 : 0,
'password' => $password ? $password : null,
'pixieset' => $pixieset,
'id_author' => $id_author ? $id_author : null
] );
$id = $mdb -> id();
if ( $id )
{
$i = 0;
/* tłumaczenia */
$results = $mdb -> select( 'pp_langs', [ 'id' ], [ 'status' => 1, 'ORDER' => [ 'o' => 'ASC' ] ] );
if ( is_array( $results ) and count( $results ) > 1 ) foreach ( $results as $row )
{
$mdb -> insert( 'pp_articles_langs', [
'article_id' => (int)$id,
'lang_id' => $row['id'],
'title' => $title[ $i ] != '' ? $title[ $i ] : null,
'main_image' => $main_image[$i] != '' ? $main_image[$i] : null,
'entry' => $entry[ $i ] != '' ? $entry[ $i ] : null,
'text' => $text[ $i ] != '' ? $text[ $i ] : null,
'table_of_contents' => $table_of_contents[$i] != '' ? $table_of_contents[$i] : null,
'meta_title' => $meta_title[ $i ] != '' ? $meta_title[ $i ] : null,
'meta_description' => $meta_description[ $i ] != '' ? $meta_description[ $i ] : null,
'meta_keywords' => $meta_keywords[ $i ] != '' ? $meta_keywords[ $i ] : null,
'seo_link' => \S::seo( $seo_link[ $i ] ) != '' ? \S::seo( $seo_link[ $i ] ) : null,
'noindex' => $noindex[ $i ],
'copy_from' => $copy_from[ $i ] != '' ? $copy_from[ $i ] : null,
'block_direct_access' => $block_direct_access[ $i ]
] );
$i++;
}
else if ( is_array( $results ) and count( $results ) == 1 ) foreach ( $results as $row )
{
$mdb -> insert( 'pp_articles_langs', [
'article_id' => (int)$id,
'lang_id' => $row['id'],
'title' => $title != '' ? $title : null,
'main_image' => $main_image != '' ? $main_image : null,
'entry' => $entry != '' ? $entry : null,
'text' => $text != '' ? $text : null,
'table_of_contents' => $table_of_contents != '' ? $table_of_contents : null,
'meta_title' => $meta_title != '' ? $meta_title : null,
'meta_description' => $meta_description != '' ? $meta_description : null,
'meta_keywords' => $meta_keywords != '' ? $meta_keywords : null,
'seo_link' => \S::seo( $seo_link ) != '' ? \S::seo( $seo_link ) : null,
'noindex' => $noindex,
'copy_from' => $copy_from != '' ? $copy_from : null,
'block_direct_access' => $block_direct_access
] );
}
/* parametry bez wersji językowych */
$results = $mdb -> select( 'pp_articles_additional_params', '*', [ 'AND' => [ 'status' => 1, 'language' => 0 ] ] );
if ( is_array( $results ) and !empty( $results ) ) foreach ( $results as $row )
{
$mdb -> insert( 'pp_articles_additional_values', [
'param_id' => $row['id'],
'value' => $params[ 'ap_' . $row['name'] ],
'article_id' => (int)$id,
'language_id' => null
] );
}
/* strony */
if ( is_array( $pages ) ) foreach ( $pages as $page )
{
$order = self::max_order() + 1;
$mdb -> insert( 'pp_articles_pages', [
'article_id' => (int)$id,
'page_id' => (int)$page,
'o' => (int)$order
] );
}
else if ( $pages )
{
$order = self::max_order() + 1;
$mdb -> insert( 'pp_articles_pages', [
'article_id' => (int)$id,
'page_id' => (int)$pages,
'o' => (int)$order
] );
}
/* pliki */
$results = $mdb -> select( 'pp_articles_files', '*', [ 'article_id' => null ] );
if ( is_array( $results ) ) foreach ( $results as $row )
{
$dir = '/upload/article_files/article_' . $id;
$new_file_name = str_replace( '/upload/article_files/tmp', $dir, $row['src'] );
if ( file_exists( '..' . $row['src'] ) )
{
if ( !is_dir( '../' . $dir ) and $created !== true )
{
if ( mkdir( '../' . $dir, 0755, true ) )
$created = true;
}
rename( '..' . $row['src'], '..' . $new_file_name );
}
$mdb -> update( 'pp_articles_files', [ 'src' => $new_file_name, 'article_id' => $id ], [ 'id' => $row['id'] ] );
}
$created = false;
/* zdjęcia */
$results = $mdb -> select( 'pp_articles_images', '*', [ 'article_id' => null ] );
if ( is_array( $results ) ) foreach ( $results as $row )
{
$dir = '/upload/article_images/article_' . $id;
$new_file_name = str_replace( '/upload/article_images/tmp', $dir, $row['src'] );
if ( file_exists( '../' . $new_file_name ) )
{
$ext = strrpos( $new_file_name, '.' );
$fileName_a = substr( $new_file_name, 0, $ext );
$fileName_b = substr( $new_file_name, $ext );
$count = 1;
while ( file_exists( '../' . $fileName_a . '_' . $count . $fileName_b ) )
$count++;
$new_file_name = $fileName_a . '_' . $count . $fileName_b;
}
if ( file_exists( '..' . $row['src'] ) )
{
if ( !is_dir( '../' . $dir ) and $created !== true )
{
if ( mkdir( '../' . $dir, 0755, true ) )
$created = true;
}
rename( '..' . $row['src'], '..' . $new_file_name );
}
$mdb -> update( 'pp_articles_images', [ 'src' => $new_file_name, 'article_id' => (int)$id ], [ 'id' => $row['id'] ] );
}
/* tagi */
$tags = explode( ',', $tags );
if ( is_array( $tags ) ) foreach ( $tags as $tag )
{
if ( trim( $tag ) != '' )
{
$tag_id = $mdb -> get( 'pp_tags', 'id', [ 'name' => $tag ] );
if ( !$tag_id )
{
$mdb -> insert( 'pp_tags', [ 'name' => $tag ] );
$tag_id = $mdb -> id();
}
$mdb -> insert( 'pp_articles_tags', [ 'article_id' => (int)$id, 'tag_id' => (int)$tag_id ] );
}
}
\S::htacces();
\S::delete_cache();
return $id;
}
}
else
{
$mdb -> update( 'pp_articles', [
'show_title' => $show_title == 'on' ? 1 : 0,
'show_date_add' => $show_date_add == 'on' ? 1 : 0,
'show_date_modify' => $show_date_modify == 'on' ? 1 : 0,
'date_modify' => date( 'Y-m-d H:i:s' ),
'modify_by' => $user['id'],
'layout_id' => $layout_id ? (int)$layout_id : null,
'status' => $status == 'on' ? 1 : 0,
'repeat_entry' => $repeat_entry == 'on' ? 1 : 0,
'social_icons' => $social_icons == 'on' ? 1 : 0,
'date_start' => $event_date[0] ? $event_date[0] : null,
'date_end' => $event_date[1] ? $event_date[1] : null,
'priority' => $priority == 'on' ? 1 : 0,
'password' => $password ? $password : null,
'pixieset' => $pixieset,
'id_author' => $id_author ? $id_author : null
], [
'id' => (int)$article_id
] );
if ( $date_add )
$mdb -> update( 'pp_articles', [ 'date_add' => $date_add ], [ 'id' => (int)$article_id ] );
$i = 0;
/* tłumaczenia */
$mdb -> delete( 'pp_articles_langs', [ 'article_id' => (int)$article_id ] );
$results = $mdb -> select( 'pp_langs', [ 'id' ], [ 'status' => 1, 'ORDER' => [ 'o' => 'ASC' ] ] );
if ( is_array( $results ) and count( $results ) > 1 ) foreach ( $results as $row )
{
$mdb -> insert( 'pp_articles_langs', [
'article_id' => (int)$article_id,
'lang_id' => $row['id'],
'title' => $title[ $i ] != '' ? $title[ $i ] : null,
'main_image' => $main_image[$i] != '' ? $main_image[$i] : null,
'entry' => $entry[ $i ] != '' ? $entry[ $i ] : null,
'text' => $text[ $i ] != '' ? $text[ $i ] : null,
'table_of_contents' => $table_of_contents[$i] != '' ? $table_of_contents[$i] : null,
'meta_title' => $meta_title[ $i ] != '' ? $meta_title[ $i ] : null,
'meta_description' => $meta_description[ $i ] != '' ? $meta_description[ $i ] : null,
'meta_keywords' => $meta_keywords[ $i ] != '' ? $meta_keywords[ $i ] : null,
'seo_link' => \S::seo( $seo_link[ $i ] ) != '' ? \S::seo( $seo_link[ $i ] ) : null,
'noindex' => $noindex[ $i ],
'copy_from' => $copy_from[ $i ] != '' ? $copy_from[ $i ] : null,
'block_direct_access' => $block_direct_access[ $i ]
] );
$i++;
}
else if ( is_array( $results ) and count( $results ) == 1 ) foreach ( $results as $row )
{
$mdb -> insert( 'pp_articles_langs', [
'article_id' => (int)$article_id,
'lang_id' => $row['id'],
'title' => $title != '' ? $title : null,
'main_image' => $main_image != '' ? $main_image : null,
'entry' => $entry != '' ? $entry : null,
'text' => $text != '' ? $text : null,
'table_of_contents' => $table_of_contents != '' ? $table_of_contents : null,
'meta_title' => $meta_title != '' ? $meta_title : null,
'meta_description' => $meta_description != '' ? $meta_description : null,
'meta_keywords' => $meta_keywords != '' ? $meta_keywords : null,
'seo_link' => \S::seo( $seo_link ) != '' ? \S::seo( $seo_link ) : null,
'noindex' => $noindex,
'copy_from' => $copy_from != '' ? $copy_from : null,
'block_direct_access' => $block_direct_access
] );
}
/* dodatkowe parametry */
$mdb -> delete( 'pp_articles_additional_values', [ 'article_id' => (int)$article_id ] );
/* parametry bez wersji językowych */
$results = $mdb -> select( 'pp_articles_additional_params', '*', [ 'AND' => [ 'status' => 1, 'language' => 0 ] ] );
if ( is_array( $results ) and !empty( $results ) ) foreach ( $results as $row )
{
$mdb -> insert( 'pp_articles_additional_values', [
'param_id' => $row['id'],
'value' => $params[ 'ap_' . $row['name'] ],
'article_id' => (int)$article_id,
'language_id' => null
] );
}
/* parametry z wersjami językowymi */
$results = $mdb -> select( 'pp_articles_additional_params', '*', [ 'AND' => [ 'status' => 1, 'language' => 1 ] ] );
if ( is_array( $results ) and !empty( $results ) ) foreach ( $results as $row )
{
$results2 = $mdb -> select( 'pp_langs', [ 'id' ], [ 'status' => 1, 'ORDER' => [ 'o' => 'ASC' ] ] );
if ( is_array( $results2 ) ) foreach ( $results2 as $row2 )
{
$mdb -> insert( 'pp_articles_additional_values', [
'param_id' => $row['id'],
'value' => $params[ 'ap_' . $row['name'] . '_' . $row2['id'] ],
'article_id' => (int)$article_id,
'language_id' => $row2['id']
] );
}
}
/* strony */
$not_in = [ 0 ];
if ( is_array( $pages ) ) foreach ( $pages as $page )
$not_in[] = $page;
else if ( $pages )
$not_in[] = $pages;
$mdb -> delete( 'pp_articles_pages', [ 'AND' => [ 'article_id' => (int)$article_id, 'page_id[!]' => $not_in ] ] );
$pages_tmp = $mdb -> select( 'pp_articles_pages', 'page_id', [ 'article_id' => (int)$article_id ] );
if ( !is_array( $pages ) )
$pages = [ $pages ];
$pages = array_diff( $pages, $pages_tmp );
if ( is_array( $pages ) ) foreach ( $pages as $page )
{
$order = self::max_order() + 1;
$mdb -> insert( 'pp_articles_pages', [
'article_id' => (int)$article_id,
'page_id' => (int)$page,
'o' => (int)$order
] );
}
/* pliki */
$results = $mdb -> select( 'pp_articles_files', '*', [ 'article_id' => null ] );
if ( is_array( $results ) ) foreach ( $results as $row )
{
$dir = '/upload/article_files/article_' . $article_id;
$new_file_name = str_replace( '/upload/article_files/tmp', $dir, $row['src'] );
if ( file_exists( '..' . $row['src'] ) )
{
if ( !is_dir( '../' . $dir ) and $created !== true )
{
if ( mkdir( '../' . $dir, 0755, true ) )
$created = true;
}
rename( '..' . $row['src'], '..' . $new_file_name );
}
$mdb -> update( 'pp_articles_files', [ 'src' => $new_file_name, 'article_id' => (int)$article_id ], [ 'id' => $row['id'] ] );
}
$created = false;
/* zdjęcia */
$results = $mdb -> select( 'pp_articles_images', '*', [ 'article_id' => null ] );
if ( is_array( $results ) ) foreach ( $results as $row )
{
$dir = '/upload/article_images/article_' . $article_id;
$new_file_name = str_replace( '/upload/article_images/tmp', $dir, $row['src'] );
if ( file_exists( '../' . $new_file_name ) )
{
$ext = strrpos( $new_file_name, '.' );
$fileName_a = substr( $new_file_name, 0, $ext );
$fileName_b = substr( $new_file_name, $ext );
$count = 1;
while ( file_exists( '../' . $fileName_a . '_' . $count . $fileName_b ) )
$count++;
$new_file_name = $fileName_a . '_' . $count . $fileName_b;
}
if ( file_exists( '..' . $row['src'] ) )
{
if ( !is_dir( '../' . $dir ) and $created !== true )
{
if ( mkdir( '../' . $dir, 0755, true ) )
$created = true;
}
rename( '..' . $row['src'], '..' . $new_file_name );
}
$mdb -> update( 'pp_articles_images', [ 'src' => $new_file_name, 'article_id' => (int)$article_id ], [ 'id' => $row['id'] ] );
}
$results = $mdb -> select( 'pp_articles_images', '*', [ 'AND' => [ 'article_id' => (int)$article_id, 'to_delete' => 1 ] ] );
if ( is_array( $results ) ) foreach ( $results as $row )
{
if ( file_exists( '../' . $row['src'] ) )
unlink( '../' . $row['src'] );
}
$mdb -> delete( 'pp_articles_images', [ 'AND' => [ 'article_id' => (int)$article_id, 'to_delete' => 1 ] ] );
$results = $mdb -> select( 'pp_articles_files', '*', [ 'AND' => [ 'article_id' => (int)$article_id, 'to_delete' => 1 ] ] );
if ( is_array( $results ) ) foreach ( $results as $row )
{
if ( file_exists( '../' . $row['src'] ) )
unlink( '../' . $row['src'] );
}
$mdb -> delete( 'pp_articles_files', [ 'AND' => [ 'article_id' => (int)$article_id, 'to_delete' => 1 ] ] );
/* tagi */
$mdb -> delete( 'pp_articles_tags', [ 'article_id' => (int)$article_id ] );
$tags = explode( ',', $tags );
if ( is_array( $tags ) ) foreach ( $tags as $tag )
{
if ( trim( $tag ) != '' )
{
$tag_id = $mdb -> get( 'pp_tags', 'id', [ 'name' => $tag ] );
if ( !$tag_id )
{
$mdb -> insert( 'pp_tags', [ 'name' => $tag ] );
$tag_id = $mdb -> id();
}
$mdb -> insert( 'pp_articles_tags', [ 'article_id' => (int)$article_id, 'tag_id' => (int)$tag_id ] );
}
}
\S::htacces();
\S::delete_cache();
return $article_id;
}
}
public static function delete_nonassigned_files()
{
global $mdb;
$results = $mdb -> select( 'pp_articles_files', '*', [ 'article_id' => null ] );
if ( is_array( $results ) ) foreach ( $results as $row )
{
if ( file_exists( '../' . $row['src'] ) )
unlink( '../' . $row['src'] );
}
$mdb -> delete( 'pp_articles_files', [ 'article_id' => null ] );
}
public static function delete_nonassigned_images()
{
global $mdb;
$results = $mdb -> select( 'pp_articles_images', '*', [ 'article_id' => null ] );
if ( is_array( $results ) ) foreach ( $results as $row )
{
if ( file_exists( '../' . $row['src'] ) )
unlink( '../' . $row['src'] );
}
$mdb -> delete( 'pp_articles_images', [ 'article_id' => null ] );
}
}
?>

View File

@@ -0,0 +1,29 @@
<?php
namespace admin\factory;
class ArticlesArchive
{
public static function article_restore( $article_id )
{
global $mdb;
return $mdb -> update( 'pp_articles', [ 'status' => 0 ], [ 'id' => (int)$article_id ] );
}
public static function article_delete( $article_id )
{
global $mdb;
$mdb -> delete( 'pp_articles_pages', [ 'article_id' => (int)$article_id ] );
$mdb -> delete( 'pp_articles_langs', [ 'article_id' => (int)$article_id ] );
$mdb -> delete( 'pp_articles_images', [ 'article_id' => (int)$article_id ] );
$mdb -> delete( 'pp_articles_files', [ 'article_id' => (int)$article_id ] );
$mdb -> delete( 'pp_articles_tags', [ 'article_id' => (int)$article_id ] );
$mdb -> delete( 'pp_articles', [ 'id' => (int)$article_id ] );
\S::delete_dir( '../upload/article_images/article_' . (int)$article_id . '/' );
\S::delete_dir( '../upload/article_files/article_' . (int)$article_id . '/' );
return true;
}
}

View File

@@ -0,0 +1,117 @@
<?
namespace admin\factory;
class Authors
{
// prosta lista autorów
static public function get_simple_list()
{
global $mdb;
return $mdb -> select( 'pp_authors', '*', [ 'ORDER' => [ 'author' => 'ASC' ] ] );
}
// usunięcie autora
static public function delete_author( $id_author )
{
global $mdb;
$result = $mdb -> delete( 'pp_authors', [ 'id' => (int)$id_author ] );
\S::delete_cache();
return $result;
}
// zapis autora
static public function save_author( $id_author, $author, $image, $description )
{
global $mdb;
if ( !$id_author )
{
$mdb -> insert( 'pp_authors', [
'author' => $author,
'image' => $image
] );
$id = $mdb -> id();
if ( $id )
{
$i = 0;
$results = $mdb -> select( 'pp_langs', [ 'id' ], [ 'status' => 1, 'ORDER' => [ 'o' => 'ASC' ] ] );
if ( is_array( $results ) and count( $results ) > 1 ) foreach ( $results as $row )
{
$mdb -> insert( 'pp_authors_langs', [
'id_author' => (int)$id,
'id_lang' => $row['id'],
'description' => $description[ $i ]
] );
$i++;
}
else if ( is_array( $results ) and count( $results ) == 1 ) foreach ( $results as $row )
{
$mdb -> insert( 'pp_authors_langs', [
'id_author' => (int)$id,
'id_lang' => $row['id'],
'description' => $description
] );
}
\S::delete_cache();
return $id;
}
}
else
{
$mdb -> update( 'pp_authors', [
'author' => $author,
'image' => $image
], [
'id' => (int)$id_author
] );
$mdb -> delete( 'pp_authors_langs', [ 'id_author' => (int)$id_author ] );
$i = 0;
$results = $mdb -> select( 'pp_langs', [ 'id' ], [ 'status' => 1, 'ORDER' => [ 'o' => 'ASC' ] ] );
if ( is_array( $results ) and count( $results ) > 1 ) foreach ( $results as $row )
{
$mdb -> insert( 'pp_authors_langs', [
'id_author' => (int)$id_author,
'id_lang' => $row['id'],
'description' => $description[ $i ]
] );
$i++;
}
else if ( is_array( $results ) and count( $results ) == 1 ) foreach ( $results as $row )
{
$mdb -> insert( 'pp_authors_langs', [
'id_author' => (int)$id_author,
'id_lang' => $row['id'],
'description' => $description
] );
}
\S::delete_cache();
return $id_author;
}
return false;
}
// szczególy autora
static public function get_single_author( $id_author )
{
global $mdb;
$author = $mdb -> get( 'pp_authors', '*', [ 'id' => (int)$id_author ] );
$results = $mdb -> select( 'pp_authors_langs', '*', [ 'id_author' => (int)$id_author ] );
if ( is_array( $results ) ) foreach ( $results as $row )
$author['languages'][$row['id_lang']] = $row;
return $author;
}
}

View File

@@ -0,0 +1,77 @@
<?php
namespace admin\factory;
class Backups
{
public static function backups_list()
{
if ( $handle = opendir( '../backups' ) )
{
while ( false !== ( $file = readdir( $handle ) ) )
{
if ( $file != "." && $file != ".." )
{
$row['name'] = $file;
$dir[] = $row;
}
}
closedir( $handle );
}
return $dir;
}
public static function backup_save()
{
global $mdb, $database;
$dbhost = $database['host'];
$dbuser = $database['user'];
$dbpsw = $database['password'];
$dbname = $database['name'];
$connection = mysqli_connect( $dbhost, $dbuser, $dbpsw, $dbname );
mysqli_set_charset( $connection, 'utf8' );
if ( !file_exists( '../backups' ) )
mkdir( "../backups", 0755 );
$backupfile = date( "Y_m_d_H_i_s" );
include('../libraries/MySQLDump.php');
$dump = new \MySQLDump( $connection );
$dump -> save( '../backups/' . $backupfile . '.sql' );
$zipTo = '../backups/' . $backupfile . '.zip';
$zip = new \ZipArchive();
$zip -> open( $zipTo, \ZipArchive::CREATE );
$folder = '../';
$iter = new \RecursiveIteratorIterator(
new \RecursiveDirectoryIterator( $folder, \RecursiveDirectoryIterator::SKIP_DOTS ),
\RecursiveIteratorIterator::SELF_FIRST,
\RecursiveIteratorIterator::CATCH_GET_CHILD
);
foreach ( $iter as $file )
{
if ( !strstr( $file, '../backups' ) and !strstr( $file, ' ../temp' ) and !strstr( $file, '../updates' ) )
{
if ( is_dir( $file ) )
{
$zip -> addEmptyDir( str_replace( $folder, '', $file . '/' ) );
}
else if ( is_file( $file ) )
{
$zip -> addFromString( str_replace( $folder, '', $file ),
file_get_contents( $file ) );
}
}
}
$zip -> close();
return true;
}
public static function backup_delete( $file )
{
if ( file_exists( '../backups/' . $file ) )
unlink( '../backups/' . $file );
return true;
}
}

View File

@@ -0,0 +1,129 @@
<?php
namespace admin\factory;
class Banners
{
public static function banner_delete( $banner_id )
{
global $mdb;
$result = $mdb -> delete( 'pp_banners', [ 'id' => (int) $banner_id ] );
\S::delete_cache();
return $result;
}
public static function banner_save( $banner_id, $name, $status, $date_start, $date_end, $home_page, $src, $url, $html, $text )
{
global $mdb;
if ( !$banner_id )
{
$mdb -> insert( 'pp_banners', [
'name' => $name,
'status' => $status == 'on' ? 1 : 0,
'date_start' => $date_start != '' ? $date_start : null,
'date_end' => $date_end != '' ? $date_end : null,
'home_page' => $home_page == 'on' ? 1 : 0
] );
$id = $mdb -> id();
if ( $id )
{
$i = 0;
$results = $mdb -> select( 'pp_langs', [ 'id' ], [ 'status' => 1, 'ORDER' => [ 'o' => 'ASC' ] ] );
if ( is_array( $results ) and count( $results ) > 1 ) foreach ( $results as $row )
{
$mdb -> insert( 'pp_banners_langs', [
'id_banner' => (int)$id,
'id_lang' => $row['id'],
'src' => $src[ $i ],
'url' => $url[ $i ],
'html' => $html[ $i ],
'text' => $text[ $i ]
] );
$i++;
}
else if ( is_array( $results ) and count( $results ) == 1 ) foreach ( $results as $row )
{
$mdb -> insert( 'pp_banners_langs', [
'id_banner' => (int)$id,
'id_lang' => $row['id'],
'src' => $src,
'url' => $url,
'html' => $html,
'text' => $text
] );
}
\S::delete_cache();
return $id;
}
}
else
{
$mdb -> update( 'pp_banners',
[
'name' => $name,
'status' => $status == 'on' ? 1 : 0,
'date_start' => $date_start != '' ? $date_start : null,
'date_end' => $date_end != '' ? $date_end : null,
'home_page' => $home_page == 'on' ? 1 : 0
], [
'id' => (int) $banner_id
] );
$mdb -> delete( 'pp_banners_langs', [ 'id_banner' => (int)$banner_id ] );
$i = 0;
$results = $mdb -> select( 'pp_langs', [ 'id' ], [ 'status' => 1, 'ORDER' => [ 'o' => 'ASC' ] ] );
if ( is_array( $results ) and count( $results ) > 1 ) foreach ( $results as $row )
{
$mdb -> insert( 'pp_banners_langs', [
'id_banner' => (int)$banner_id,
'id_lang' => $row['id'],
'src' => $src[ $i ],
'url' => $url[ $i ],
'html' => $html[ $i ],
'text' => $text[ $i ]
] );
$i++;
}
else if ( is_array( $results ) and count( $results ) == 1 ) foreach ( $results as $row )
{
$mdb -> insert( 'pp_banners_langs', [
'id_banner' => (int)$banner_id,
'id_lang' => $row['id'],
'src' => $src,
'url' => $url,
'html' => $html,
'text' => $text
] );
}
\S::delete_cache();
return $banner_id;
}
return false;
}
public static function banner_details( $id_banner )
{
global $mdb;
$banner = $mdb -> get( 'pp_banners', '*', [ 'id' => (int)$id_banner ] );
$results = $mdb -> select( 'pp_banners_langs', '*', [ 'id_banner' => (int)$id_banner ] );
if ( is_array( $results ) ) foreach ( $results as $row )
$banner['languages'][$row['id_lang']] = $row;
return $banner;
}
}
?>

View File

@@ -0,0 +1,11 @@
<?php
namespace admin\factory;
class Emails
{
public static function email_details( $email_id )
{
global $mdb;
return $mdb -> get( 'pp_contact_emails', '*', [ 'id' => (int)$email_id ] );
}
}

View File

@@ -0,0 +1,181 @@
<?
namespace admin\factory;
class Languages
{
public static function available_domains()
{
global $mdb;
return $mdb -> query( 'SELECT domain FROM pp_langs WHERE status = 1 AND domain IS NOT NULL GROUP BY domain' ) -> fetchAll( \PDO::FETCH_ASSOC );
}
public static function default_domain()
{
global $mdb;
$results = $mdb -> query( 'SELECT domain FROM pp_langs WHERE status = 1 AND domain IS NOT NULL AND main_domain = 1' ) -> fetchAll();
return $default_domain = $results[0][0];
}
public static function translation_delete( $translation_id )
{
global $mdb;
return $mdb -> delete( 'pp_langs_translations', [ 'id' => $translation_id ] );
}
public static function translation_save( $translation_id, $text, $languages )
{
global $mdb;
if ( $translation_id )
{
$mdb -> update( 'pp_langs_translations', [ 'text' => $text ], [ 'id' => $translation_id ] );
if ( is_array( $languages ) and !empty( $languages ) ): foreach ( $languages as $key => $val ):
$mdb -> update( 'pp_langs_translations', [ $key => $val ], [ 'id' => $translation_id ] );
endforeach; endif;
\S::htacces();
\S::delete_cache();
return $translation_id;
}
else
{
$mdb -> insert( 'pp_langs_translations', [ 'text' => $text ] );
if ( $translation_id = $mdb -> id() )
{
if ( is_array( $languages ) and !empty( $languages ) ): foreach ( $languages as $key => $val ):
$mdb -> update( 'pp_langs_translations', [ $key => $val ], [ 'id' => $translation_id ] );
endforeach; endif;
}
\S::htacces();
\S::delete_cache();
return $translation_id;
}
}
public static function translation_details( $translation_id )
{
global $mdb;
return $mdb -> get( 'pp_langs_translations', '*', [ 'id' => $translation_id ] );
}
public static function language_delete( $language_id )
{
global $mdb;
if ( $mdb -> count( 'pp_langs' ) > 1 )
{
if ( $mdb -> query( 'ALTER TABLE pp_langs_translations DROP ' . $language_id )
and
$mdb -> delete( 'pp_langs', [ 'id' => $language_id ] )
)
return true;
}
return false;
}
public static function max_order()
{
global $mdb;
return $mdb -> max( 'pp_langs', 'o' );
}
public static function language_save( $language_id, $name, $status, $start, $o, $domain, $main_domain )
{
global $mdb;
if ( $start == 'on' and $status == 'on' and !\S::get_domain( $domain ) )
$mdb -> update( 'pp_langs', [
'start' => 0
], [
'id[!]' => $language_id
] );
if ( $start == 'on' and $status == 'on' and \S::get_domain( $domain ) )
$mdb -> update( 'pp_langs', [
'start' => 0
], [
'AND' => [ 'id[!]' => $language_id, 'domain' => \S::get_domain( $domain ) ]
] );
if ( $main_domain == 'on' and $domain and $status == 'on' )
$mdb -> update( 'pp_langs', [
'main_domain' => 0
], [
' id[!]' => $language_id
] );
if ( $mdb -> count( 'pp_langs', [ 'id' => $language_id ] ) )
{
$mdb -> update( 'pp_langs', [
'status' => $status == 'on' ? 1 : 0,
'start' => $start == 'on' ? 1 : 0,
'name' => $name,
'o' => $o,
'domain' => \S::get_domain( $domain ) ? \S::get_domain( $domain ) : null,
'main_domain' => $main_domain == 'on' and \S::get_domain( $domain ) ? 1 : 0,
], [
'id' => $language_id
] );
}
else
{
if ( $mdb -> query( 'ALTER TABLE pp_langs_translations ADD ' . strtolower( $language_id ) . ' TEXT NULL DEFAULT NULL' ) )
{
$mdb -> insert( 'pp_langs', [
'id' => strtolower( $language_id ),
'name' => $name,
'status' => $status == 'on' ? 1 : 0,
'start' => $start == 'on' ? 1 : 0,
'o' => $o,
'domain' => \S::get_domain( $domain ) ? \S::get_domain( $domain ) : null,
'main_domain' => $main_domain == 'on' && \S::get_domain( $domain ) ? 1 : 0,
] );
}
}
if ( !$mdb -> count( 'pp_langs', [ 'AND' => [ 'status' => 1, 'domain[!]' => null ] ] ) )
{
if ( !$mdb -> count( 'pp_langs', [ 'AND' => [ 'status' => 1, 'start' => 1, 'domain' => null ] ] ) )
{
if ( $id_tmp = $mdb -> get( 'pp_langs', 'id', [ 'status' => 1, 'ORDER' => [ 'o' => 'ASC' ] ] ) )
$mdb -> update( 'pp_langs', [ 'start' => 1 ], [ 'id' => $id_tmp ] );
}
}
$domains = $mdb -> select( 'pp_langs', 'domain', [ 'domain[!]' => null, 'GROUP' => 'domain'] );
if ( is_array( $domains ) and !empty( $domains ) )
{
$mdb -> update( 'pp_langs', [ 'start' => 0 ], [ 'domain' => null ] );
foreach ( $domains as $domain )
{
if ( !$mdb -> count( 'pp_langs', [ 'AND' => [ 'status' => 1, 'start' => 1, 'domain' => $domain ] ] ) )
{
if ( $id_tmp = $mdb -> get( 'pp_langs', 'id', [ 'AND' => [ 'status' => 1, 'domain' => $domain ], 'ORDER' => [ 'o' => 'ASC' ] ] ) )
$mdb -> update( 'pp_langs', [ 'start' => 1 ], [ 'id' => $id_tmp ] );
}
}
}
if ( !$mdb -> count( 'pp_langs', [ 'AND' => [ 'status' => 1, 'main_domain' => 1 ] ] ) )
{
if ( $id_tmp = $mdb -> get( 'pp_langs', 'id', [ 'AND' => [ 'status' => 1, 'domain[!]' => null ], 'ORDER' => [ 'o' => 'ASC' ] ] ) )
$mdb -> update( 'pp_langs', [ 'main_domain' => 1 ], [ 'id' => $id_tmp ] );
}
\S::htacces();
\S::delete_cache();
return $language_id;
}
public static function language_details( $language_id )
{
global $mdb;
return $mdb -> get( 'pp_langs', '*', [ 'id' => $language_id ] );
}
public static function languages_list()
{
global $mdb;
return $mdb -> select( 'pp_langs', '*', [ 'ORDER' => [ 'o' => 'ASC' ] ] );
}
}
?>

View File

@@ -0,0 +1,141 @@
<?php
namespace admin\factory;
class Layouts
{
public static function layout_delete( $layout_id )
{
global $mdb;
if ( $mdb -> count( 'pp_layouts' ) > 1 )
return $mdb -> delete( 'pp_layouts', [ 'id' => (int)$layout_id ] );
return false;
}
public static function layout_details( $layout_id )
{
global $mdb;
$layout = $mdb -> get( 'pp_layouts', '*', [ 'id' => (int)$layout_id ] );
$layout['pages'] = $mdb -> select( 'pp_layouts_pages', 'page_id', [ 'layout_id' => (int)$layout_id ] );
return $layout;
}
public static function layout_save( $layout_id, $name, $status, $pages, $html, $css, $js, $m_html, $m_css, $m_js )
{
global $mdb;
if ( !$layout_id )
{
if ( $status == 'on' )
$mdb -> update( 'pp_layouts', [ 'status' => 0 ] );
$mdb -> insert( 'pp_layouts', [
'name' => $name,
'html' => $html,
'css' => $css,
'js' => $js,
'm_html' => $m_html,
'm_css' => $m_css,
'm_js' => $m_js,
'status' => $status == 'on' ? 1 : 0
] );
$id = $mdb -> id();
if ( $id )
{
if ( is_array( $pages ) ) foreach ( $pages as $page )
{
$mdb -> delete( 'pp_layouts_pages', [ 'page_id' => (int)$page ] );
$mdb -> insert( 'pp_layouts_pages', [
'layout_id' => (int)$id,
'page_id' => (int)$page
] );
}
else if ( $pages )
{
$mdb -> delete( 'pp_layouts_pages', [ 'page_id' => (int)$pages ] );
$mdb -> insert( 'pp_layouts_pages', [
'layout_id' => (int)$id,
'page_id' => (int)$pages
] );
}
\S::delete_cache();
return $id;
}
}
else
{
if ( $status == 'on' )
$mdb -> update( 'pp_layouts', [ 'status' => 0 ] );
$mdb -> update( 'pp_layouts', [
'name' => $name,
'html' => $html,
'css' => $css,
'js' => $js,
'm_html' => $m_html,
'm_css' => $m_css,
'm_js' => $m_js,
'status' => $status == 'on' ? 1 : 0
], [
'id' => $layout_id
] );
$mdb -> delete( 'pp_layouts_pages', [ 'layout_id' => (int)$layout_id ] );
if ( is_array( $pages ) ) foreach ( $pages as $page )
{
$mdb -> delete( 'pp_layouts_pages', [ 'page_id' => (int)$page ] );
$mdb -> insert( 'pp_layouts_pages', [
'layout_id' => (int)$layout_id,
'page_id' => (int)$page
] );
}
else if ( $pages )
{
$mdb -> delete( 'pp_layouts_pages', [ 'page_id' => (int)$pages ] );
$mdb -> insert( 'pp_layouts_pages', [
'layout_id' => (int)$layout_id,
'page_id' => (int)$pages
] );
}
\S::delete_cache();
return $layout_id;
}
return false;
}
public static function menus_list()
{
global $mdb;
$results = $mdb -> select( 'pp_menus', 'id', [ 'ORDER' => [ 'name' => 'ASC' ] ] );
if ( is_array( $results ) ) foreach ( $results as $row )
{
$menu = \admin\factory\Pages::menu_details( $row );
$menu['pages'] = \admin\factory\Pages::menu_pages( $row );
$menus[] = $menu;
}
return $menus;
}
public static function layouts_list()
{
global $mdb;
return $mdb -> select( 'pp_layouts', '*', [ 'ORDER' => [ 'name' => 'ASC' ] ] );
}
}
?>

View File

@@ -0,0 +1,105 @@
<?php
namespace admin\factory;
class Newsletter
{
public static function emails_import( $emails )
{
global $mdb;
$emails = explode( PHP_EOL, $emails );
if ( is_array( $emails ) ) foreach ( $emails as $email )
{
if ( trim( $email ) and !$mdb -> count( 'pp_newsletter', [ 'email' => trim( $email ) ] ) )
$mdb -> insert( 'pp_newsletter', [
'email' => trim( $email ),
'hash' => md5( $email . time() ),
'status' => 1
] );
}
return true;
}
public static function is_admin_template( $template_id )
{
global $mdb;
return $mdb -> get( 'pp_newsletter_templates', 'is_admin', [ 'id' => (int)$template_id ] );
}
public static function newsletter_template_delete( $template_id )
{
global $mdb;
return $mdb -> delete( 'pp_newsletter_templates', [ 'id' => (int)$template_id ] );
}
public static function send( $dates, $template, $only_once )
{
global $mdb;
$results = $mdb -> select( 'pp_newsletter', 'email', [ 'status' => 1 ] );
if ( is_array( $results ) and !empty( $results ) ) foreach ( $results as $row )
{
if ( $template and $only_once )
{
if ( !$mdb -> count( 'pp_newsletter_send', [ 'AND' => [ 'id_template' => $template, 'email' => $row ] ] ) )
$mdb -> insert( 'pp_newsletter_send', [
'email' => $row,
'dates' => $dates,
'id_template' => $template ? $template : null,
'only_once' => ( $only_once == 'on' and $template ) ? 1 : 0
] );
}
else
$mdb -> insert( 'pp_newsletter_send', [
'email' => $row,
'dates' => $dates,
'id_template' => $template ? $template : null,
'only_once' => ( $only_once == 'on' and $template ) ? 1 : 0
] );
}
return true;
}
public static function email_template_detalis ($id_template)
{
global $mdb;
$result = $mdb -> get ('pp_newsletter_templates', '*', [ 'id' => (int)$id_template ] );
return $result;
}
public static function template_save($id, $name, $text)
{
global $mdb;
if ( !$id )
{
if ( $mdb -> insert( 'pp_newsletter_templates', [
'name' => $name,
'text' => $text
] ) )
{
\S::delete_cache();
return $mdb -> id();
}
}
else
{
$mdb -> update( 'pp_newsletter_templates', [
'name' => $name,
'text' => $text
], [
'id' => (int)$id
] );
\S::delete_cache();
return $id;
}
}
public static function templates_list()
{
global $mdb;
return $mdb -> select( 'pp_newsletter_templates', '*', [ 'is_admin' => 0, 'ORDER' => [ 'name' => 'ASC' ] ] );
}
}

View File

@@ -0,0 +1,509 @@
<?
namespace admin\factory;
class Pages
{
public static $_page_types = [ 0 => 'pełne artykuły', 1 => 'wprowadzenia', 2 => 'miniaturki', 3 => 'link', 4 => 'kontakt' ];
public static $_sort_types = [
0 => 'data dodania - najstarsze na początku',
1 => 'data dodania - najnowsze na początku',
2 => 'data modyfikacji - rosnąco',
3 => 'data mofyfikacji - malejąco',
4 => 'ręczne',
5 => 'alfabetycznie - A - Z',
6 => 'alfabetycznie - Z - A'
];
public static function save_articles_order( $page_id, $articles )
{
global $mdb;
if ( is_array( $articles ) )
{
$mdb -> update( 'pp_articles_pages', [ 'o' => 0 ],
[ 'page_id' => (int) $page_id ] );
for ( $i = 0; $i < count( $articles ); $i++ )
{
if ( $articles[$i]['item_id'] )
{
$x++;
$mdb -> update( 'pp_articles_pages', [ 'o' => $x ],
[ 'AND' => [ 'page_id' => (int) $page_id, 'article_id' => $articles[$i]['item_id'] ] ] );
}
}
}
return true;
}
public static function page_articles( $page_id )
{
global $mdb;
$results = $mdb -> query( 'SELECT '
. 'article_id, o, status '
. 'FROM '
. 'pp_articles_pages AS ap '
. 'INNER JOIN pp_articles AS a ON a.id = ap.article_id '
. 'WHERE '
. 'page_id = ' . (int) $page_id . ' AND status != -1 '
. 'ORDER BY '
. 'o ASC' ) -> fetchAll();
if ( is_array( $results ) )
foreach ( $results as $row )
{
$row['title'] = \admin\factory\Articles::article_title( $row['article_id'] );
$articles[] = $row;
}
return $articles;
}
public static function menus_list()
{
global $mdb;
return $mdb -> select( 'pp_menus', '*', [ 'ORDER' => [ 'name' => 'ASC' ] ] );
}
public static function save_pages_order( $menu_id, $pages )
{
global $mdb;
if ( is_array( $pages ) )
{
$mdb -> update( 'pp_pages', [ 'o' => 0 ], [ 'menu_id' => (int) $menu_id ] );
for ( $i = 0; $i < count( $pages ); $i++ )
{
if ( $pages[$i]['item_id'] )
{
$pages[$i]['parent_id'] ? $parent_id = $pages[$i]['parent_id'] : $parent_id = 0;
if ( $pages[$i]['item_id'] && $pages[$i]['depth'] > 1 )
{
if ( $pages[$i]['depth'] == 2 )
$parent_id = null;
$x++;
$mdb -> update( 'pp_pages', [ 'o' => $x, 'parent_id' => $parent_id ],
[ 'id' => (int) $pages[$i]['item_id'] ] );
}
}
}
}
\S::delete_cache();
return true;
}
public static function page_delete( $page_id )
{
global $mdb;
if ( $mdb -> count( 'pp_pages', [ 'parent_id' => (int) $page_id ] ) )
return false;
if ( $mdb -> delete( 'pp_pages', [ 'id' => (int) $page_id ] ) )
{
\S::delete_cache();
\S::htacces();
return true;
}
return false;
}
public static function max_order()
{
global $mdb;
return $mdb -> max( 'pp_pages', 'o' );
}
public static function page_save(
$page_id, $title, $seo_link, $meta_title, $meta_description, $meta_keywords, $menu_id, $parent_id, $page_type, $sort_type, $layout_id, $articles_limit, $show_title, $status, $link, $noindex, $start,
$site_title, $block_direct_access, $cache, $canonical
)
{
global $mdb;
if ( !$parent_id )
$parent_id = null;
if ( !$page_id )
{
$order = self::max_order() + 1;
$mdb -> insert( 'pp_pages', [
'menu_id' => (int) $menu_id,
'page_type' => $page_type,
'sort_type' => $sort_type,
'articles_limit' => $articles_limit,
'show_title' => $show_title == 'on' ? 1 : 0,
'status' => $status == 'on' ? 1 : 0,
'o' => (int) $order,
'parent_id' => $parent_id,
'start' => $start == 'on' ? 1 : 0,
'cache' => $cache == 'on' ? 1 : 0
] );
$id = $mdb -> id();
if ( $id )
{
if ( $start )
$mdb -> update( 'pp_pages', [ 'start' => 0 ], [ 'id[!]' => (int)$id ] );
if ( $layout_id )
$mdb -> insert( 'pp_layouts_pages', [ 'page_id' => (int) $id, 'layout_id' => (int)$layout_id ] );
$i = 0;
$results = $mdb -> select( 'pp_langs', [ 'id' ], [ 'status' => 1, 'ORDER' => [ 'o' => 'ASC' ] ] );
if ( is_array( $results ) and count( $results ) > 1 ) foreach ( $results as $row )
{
$mdb -> insert( 'pp_pages_langs', [
'page_id' => (int) $id,
'lang_id' => $row['id'],
'title' => $title[$i] != '' ? $title[$i] : null,
'meta_description' => $meta_description[$i] != '' ? $meta_description[$i] : null,
'meta_keywords' => $meta_keywords[$i] != '' ? $meta_keywords[$i] : null,
'meta_title' => $meta_title[$i] != '' ? $meta_title[$i] : null,
'seo_link' => \S::seo( $seo_link[$i] ) != '' ? \S::seo( $seo_link[$i] ) : null,
'noindex' => $noindex[$i],
'site_title' => $site_title[$i] != '' ? $site_title[$i] : null,
'link' => $link[$i] != '' ? $link[$i] : null,
'block_direct_access' => $block_direct_access[$i],
'canonical' => $canonical[$i] != '' ? $canonical[$i] : null
] );
$i++;
}
else if ( is_array( $results ) and count( $results ) == 1 )
{
foreach ( $results as $row )
{
$mdb -> insert( 'pp_pages_langs', [
'page_id' => (int) $id,
'lang_id' => $row['id'],
'title' => $title != '' ? $title : null,
'meta_description' => $meta_description != '' ? $meta_description : null,
'meta_keywords' => $meta_keywords != '' ? $meta_keywords : null,
'meta_title' => $meta_title != '' ? $meta_title : null,
'seo_link' => \S::seo( $seo_link ) != '' ? \S::seo( $seo_link ) : null,
'noindex' => $noindex,
'site_title' => $site_title != '' ? $site_title : null,
'link' => $link != '' ? $link : null,
'block_direct_access' => $block_direct_access,
'canonical' => $canonical != '' ? $canonical : null
] );
}
}
\S::htacces();
\S::delete_cache();
return $id;
}
}
else
{
$mdb -> update( 'pp_pages',
[
'menu_id' => (int) $menu_id,
'page_type' => $page_type,
'sort_type' => $sort_type,
'articles_limit' => $articles_limit,
'show_title' => $show_title == 'on' ? 1 : 0,
'status' => $status == 'on' ? 1 : 0,
'parent_id' => $parent_id,
'start' => $start == 'on' ? 1 : 0,
'cache' => $cache == 'on' ? 1 : 0
], [
'id' => (int) $page_id
] );
if ( $layout_id )
{
$mdb -> delete( 'pp_layouts_pages', [ 'page_id' => (int) $page_id ] );
$mdb -> insert( 'pp_layouts_pages',
[ 'layout_id' => (int) $layout_id, 'page_id' => (int) $page_id ] );
}
if ( $start )
$mdb -> update( 'pp_pages', [ 'start' => 0 ],
[ 'id[!]' => (int) $page_id ] );
$i = 0;
$mdb -> delete( 'pp_pages_langs', [ 'page_id' => (int) $page_id ] );
$results = $mdb -> select( 'pp_langs', [ 'id' ],
[ 'status' => 1, 'ORDER' => [ 'o' => 'ASC' ] ] );
if ( is_array( $results ) and count( $results ) > 1 )
foreach ( $results as $row )
{
$mdb -> insert( 'pp_pages_langs',
[
'page_id' => (int) $page_id,
'lang_id' => $row['id'],
'title' => $title[$i] != '' ? $title[$i] : null,
'meta_description' => $meta_description[$i] != '' ? $meta_description[$i] : null,
'meta_keywords' => $meta_keywords[$i] != '' ? $meta_keywords[$i] : null,
'meta_title' => $meta_title[$i] != '' ? $meta_title[$i] : null,
'seo_link' => \S::seo( $seo_link[$i] ) != '' ? \S::seo( $seo_link[$i] ) : null,
'noindex' => $noindex[$i],
'site_title' => $site_title[$i] != '' ? $site_title[$i] : null,
'link' => $link[$i] != '' ? $link[$i] : null,
'block_direct_access' => $block_direct_access[$i],
'canonical' => $canonical[$i] != '' ? $canonical[$i] : null
] );
$i++;
}
else if ( is_array( $results ) and count( $results ) == 1 )
foreach ( $results as $row )
{
$mdb -> insert( 'pp_pages_langs',
[
'page_id' => (int) $page_id,
'lang_id' => $row['id'],
'title' => $title != '' ? $title : null,
'meta_description' => $meta_description != '' ? $meta_description : null,
'meta_keywords' => $meta_keywords != '' ? $meta_keywords : null,
'meta_title' => $meta_title != '' ? $meta_title : null,
'seo_link' => \S::seo( $seo_link ) != '' ? \S::seo( $seo_link ) : null,
'noindex' => $noindex,
'site_title' => $site_title != '' ? $site_title : null,
'link' => $link != '' ? $link : null,
'block_direct_access' => $block_direct_access,
'canonical' => $canonical != '' ? $canonical : null
] );
}
self::update_supages_menu_id( $page_id, $menu_id );
\S::htacces();
\S::delete_cache();
return $page_id;
}
return false;
}
public static function update_supages_menu_id( $parent_id, $menu_id )
{
global $mdb;
$mdb -> update( 'pp_pages', [ 'menu_id' => (int) $menu_id ],
[ 'parent_id' => $parent_id ] );
$results = $mdb -> select( 'pp_pages', [ 'id' ], [ 'parent_id' => $parent_id ] );
if ( is_array( $results ) )
foreach ( $results as $row )
self::update_supages_menu_id( $row['id'], $menu_id );
}
public static function generate_seo_link( $title, $page_id, $article_id,
$lang, $pid )
{
global $mdb;
$seo_link = \S::seo( $title );
while ( !$seo_link_check )
{
if ( $mdb -> count( 'pp_pages_langs',
[ 'AND' => [ 'seo_link' => $seo_link, 'page_id[!]' => (int) $page_id ] ] ) )
$seo_link = $seo_link . '-' . ( ++$i );
else
$seo_link_check = true;
}
$seo_link_check = false;
while ( !$seo_link_check )
{
if ( $mdb -> count( 'pp_articles_langs',
[ 'AND' => [ 'seo_link' => $seo_link, 'article_id[!]' => (int) $article_id ] ] ) )
$seo_link = $seo_link . '-' . ( ++$i );
else
$seo_link_check = true;
}
return $seo_link;
}
public static function google_url_preview( $page_id, $title, $lang, $pid, $id, $seo_link, $language_link = '' )
{
global $mdb;
$prefix = $language_link;
$status = true;
$id_page = $page_id;
do
{
if ( $page_id )
{
$parent = \admin\factory\Pages::page_details( $page_id );
$parent_id = $parent['parent_id'];
}
else
$parent_id = $pid;
if ( $parent_id )
{
$results = $mdb -> query( "SELECT title, seo_link, page_id FROM pp_pages_langs AS ppl, pp_langs AS pl WHERE lang_id = pl.id AND page_id = " . (int) $parent_id . " AND ppl.lang_id = '" . $lang . "' " ) -> fetchAll();
if ( $results[0]['seo_link'] )
$seo = $results[0]['seo_link'] . '/' . $seo;
else
$seo = 's-' . $results[0]['page_id'] . '-' . \S::seo( $results[0]['title'] ) . '/' . $seo;
$page_id = $results[0]['page_id'];
}
else
$status = false;
}
while ( $status );
if ( $id )
{
if ( !$seo_link )
$seo = $seo . 's-' . $id . '-' . \S::seo( $title );
else
$seo = $seo . $seo_link;
}
else
{
if ( !$seo_link )
$seo = $seo . 's-' . $id_page . '-' . \S::seo( $title );
else
$seo = $seo . $seo_link;
}
if ( $prefix )
$seo = $prefix . $seo;
return $seo;
}
public static function menu_delete( $menu_id )
{
global $mdb;
if ( $mdb -> count( 'pp_pages', [ 'menu_id' => (int) $menu_id ] ) )
return false;
return $mdb -> delete( 'pp_menus', [ 'id' => (int) $menu_id ] );
}
public static function menu_details( $menu_id )
{
global $mdb;
return $mdb -> get( 'pp_menus', '*', [ 'id' => (int) $menu_id ] );
}
public static function menu_save( $menu_id, $name, $status )
{
global $mdb;
$status == 'on' ? $status = 1 : $status = 0;
if ( !$menu_id )
{
return $mdb -> insert( 'pp_menus',
[
'name' => $name,
'status' => $status
] );
}
else
{
$mdb -> update( 'pp_menus',
[
'name' => $name,
'status' => $status
], [
'id' => (int) $menu_id
] );
return true;
}
return false;
}
public static function menu_lists()
{
global $mdb;
return $mdb -> select( 'pp_menus', '*', [ 'ORDER' => [ 'id' => 'ASC' ] ] );
}
public static function page_details( $page_id )
{
global $mdb;
$page = $mdb -> get( 'pp_pages', '*', [ 'id' => (int) $page_id ] );
$results = $mdb -> select( 'pp_pages_langs', '*',
[ 'page_id' => (int) $page_id ] );
if ( is_array( $results ) )
foreach ( $results as $row )
$page['languages'][$row['lang_id']] = $row;
$page['layout_id'] = $mdb -> get( 'pp_layouts_pages', 'layout_id',
[ 'page_id' => (int) $page_id ] );
return $page;
}
public static function page_url( $page_id )
{
global $mdb;
$results = $mdb -> query( "SELECT seo_link, title lang_id FROM pp_pages_langs AS ppl, pp_langs AS pl WHERE lang_id = pl.id AND page_id = " . (int) $page_id . " AND seo_link != '' ORDER BY o ASC LIMIT 1" ) -> fetchAll();
if ( !$results[0]['seo_link'] )
{
$title = self::page_title( $article_id );
return 's-' . $page_id . '-' . \S::seo( $title );
}
else
return $results[0]['seo_link'];
}
public static function page_title( $page_id )
{
global $mdb;
$result = $mdb -> select( 'pp_pages_langs',
[ '[><]pp_langs' => [ 'lang_id' => 'id' ] ], 'title',
[ 'AND' => [ 'page_id' => (int) $page_id, 'title[!]' => '' ], 'ORDER' => [ 'o' => 'ASC' ], 'LIMIT' => 1 ] );
return $result[0];
}
public static function page_languages( $page_id )
{
global $mdb;
return $mdb -> select( 'pp_pages_langs', '*',
[ 'AND' => [ 'page_id' => (int) $page_id, 'title[!]' => null ] ] );
}
public static function menu_pages( $menu_id, $parent_id = null )
{
global $mdb;
$results = $mdb -> select( 'pp_pages',
[ 'id', 'menu_id', 'status', 'parent_id', 'start' ],
[ 'AND' => [ 'menu_id' => $menu_id, 'parent_id' => $parent_id ], 'ORDER' => [ 'o' => 'ASC' ] ] );
if ( is_array( $results ) )
foreach ( $results as $row )
{
$row['title'] = self::page_title( $row['id'] );
$row['languages'] = self::page_languages( $row['id'] );
$row['subpages'] = self::menu_pages( $menu_id, $row['id'] );
$pages[] = $row;
}
return $pages;
}
}
?>

View File

@@ -0,0 +1,121 @@
<?php
namespace admin\factory;
class Scontainers
{
public static function container_delete( $container_id )
{
global $mdb;
return $mdb -> delete( 'pp_scontainers', [ 'id' => (int) $container_id ] );
}
public static function container_save( $container_id, $title, $text, $status, $show_title, $src, $html )
{
global $mdb;
if ( !$container_id )
{
$mdb -> insert( 'pp_scontainers',
[
'status' => $status == 'on' ? 1 : 0,
'show_title' => $show_title == 'on' ? 1 : 0,
'src' => $src
] );
$id = $mdb -> id();
if ( $id )
{
$i = 0;
$results = $mdb -> select( 'pp_langs', [ 'id' ], [ 'status' => 1, 'ORDER' => [ 'o' => 'ASC' ] ] );
if ( is_array( $results ) and count( $results ) > 1 ) foreach ( $results as $row )
{
$mdb -> insert( 'pp_scontainers_langs',
[
'container_id' => (int) $id,
'lang_id' => $row['id'],
'title' => $title[$i],
'text' => $text[$i],
'html' => $html[$i]
] );
$i++;
}
else if ( is_array( $results ) and count( $results ) == 1 ) foreach ( $results as $row )
{
$mdb -> insert( 'pp_scontainers_langs', [
'container_id' => (int) $id,
'lang_id' => $row['id'],
'title' => $title,
'text' => $text,
'html' => $html
] );
}
\S::delete_cache();
return $id;
}
}
else
{
$mdb -> update( 'pp_scontainers',
[
'status' => $status == 'on' ? 1 : 0,
'show_title' => $show_title == 'on' ? 1 : 0,
'src' => $src
],
[
'id' => (int) $container_id
] );
$mdb -> delete( 'pp_scontainers_langs',
[ 'container_id' => (int) $container_id ] );
$i = 0;
$results = $mdb -> select( 'pp_langs', [ 'id' ], [ 'status' => 1, 'ORDER' => [ 'o' => 'ASC' ] ] );
if ( is_array( $results ) and count( $results ) > 1 ) foreach ( $results as $row )
{
$mdb -> insert( 'pp_scontainers_langs',
[
'container_id' => (int) $container_id,
'lang_id' => $row['id'],
'title' => $title[$i],
'text' => $text[$i],
'html' => $html[$i]
] );
$i++;
}
else if ( is_array( $results ) and count( $results ) == 1 ) foreach ( $results as $row )
{
$mdb -> insert( 'pp_scontainers_langs',
[
'container_id' => (int) $container_id,
'lang_id' => $row['id'],
'title' => $title,
'text' => $text,
'html' => $html
] );
}
\S::delete_cache();
return $container_id;
}
}
public static function container_details( $container_id )
{
global $mdb;
$container = $mdb -> get( 'pp_scontainers', '*', [ 'id' => (int) $container_id ] );
$results = $mdb -> select( 'pp_scontainers_langs', '*', [ 'container_id' => (int) $container_id ] );
if ( is_array( $results ) ) foreach ( $results as $row )
$container['languages'][$row['lang_id']] = $row;
return $container;
}
}

View File

@@ -0,0 +1,55 @@
<?php
namespace admin\factory;
class SeoAdditional
{
public static function element_delete( $element_id )
{
global $mdb;
return $mdb -> delete( 'pp_seo_additional', [ 'id' => (int)$element_id ] );
}
public static function element_save( $id, $url, $status, $title, $keywords, $description, $text )
{
global $mdb;
if ( !$id )
{
if ( $mdb -> insert( 'pp_seo_additional', [
'url' => $url,
'status' => $status == 'on' ? 1 : 0,
'title' => $title,
'keywords' => $keywords,
'description' => $description,
'text' => $text
] ) )
{
\S::delete_cache();
return $mdb -> id();
}
}
else
{
$mdb -> update( 'pp_seo_additional', [
'url' => $url,
'status' => $status == 'on' ? 1 : 0,
'title' => $title,
'keywords' => $keywords,
'description' => $description,
'text' => $text
], [
'id' => (int)$id
] );
\S::delete_cache();
return $id;
}
}
public static function element_details( $element_id )
{
global $mdb;
$result = $mdb -> get ( 'pp_seo_additional', '*', [ 'id' => (int)$element_id ] );
return $result;
}
}

View File

@@ -0,0 +1,147 @@
<?
namespace admin\factory;
class Settings
{
public static function settings_update( $param, $value )
{
global $mdb;
if ( $mdb -> count( 'pp_settings', [ 'param' => $param ] ) )
return $mdb -> update( 'pp_settings', [ 'value' => $value ], [ 'param' => $param ] );
else
return $mdb -> insert( 'pp_settings', [ 'param' => $param, 'value' => $value ] );
}
public static function settings_save(
$firm_name, $firm_adress, $additional_info, $contact_form, $contact_email, $email_host, $email_port, $email_login, $email_password, $google_maps,
$facebook_link, $statistic_code, $htaccess, $robots, $newsletter_header, $newsletter_footer_1, $newsletter_footer_2, $google_map_key, $google_search_console, $update, $devel,
$news_limit, $visit_counter, $calendar, $tags, $ssl, $mysql_debug, $htaccess_cache, $visits, $links_structure, $link_version, $widget_phone, $update_key )
{
global $mdb;
$mdb -> query( 'TRUNCATE pp_settings' );
$mdb -> insert( 'pp_settings', [
[
'param' => 'firm_name',
'value' => $firm_name,
], [
'param' => 'firm_adress',
'value' => $firm_adress
], [
'param' => 'additional_info',
'value' => $additional_info
], [
'param' => 'contact_form',
'value' => $contact_form
], [
'param' => 'contact_email',
'value' => $contact_email
], [
'param' => 'email_host',
'value' => $email_host
], [
'param' => 'email_port',
'value' => $email_port
], [
'param' => 'email_login',
'value' => $email_login
], [
'param' => 'email_password',
'value' => $email_password
], [
'param' => 'google_maps',
'value' => $google_maps == 'on' ? 1 : 0
], [
"param" => 'facebook_link',
'value' => $facebook_link
], [
'param' => 'statistic_code',
'value' => $statistic_code
], [
'param' => 'htaccess',
'value' => $htaccess
], [
'param' => 'robots',
'value' => $robots
], [
'param' => 'newsletter_header',
'value' => $newsletter_header
], [
'param' => 'newsletter_footer_1',
'value' => $newsletter_footer_1
], [
'param' => 'newsletter_footer_2',
'value' => $newsletter_footer_2
], [
'param' => 'google_map_key',
'value' => $google_map_key
], [
'param' => 'google_search_console',
'value' => $google_search_console
], [
'param' => 'update',
'value' => $update == 'on' ? 1 : 0
], [
'param' => 'devel',
'value' => $devel == 'on' ? 1 : 0
], [
'param' => 'news_limit',
'value' => $news_limit
], [
'param' => 'visit_counter',
'value' => $visit_counter == 'on' ? 1 : 0
], [
'param' => 'calendar',
'value' => $calendar == 'on' ? 1 : 0
], [
'param' => 'tags',
'value' => $tags == 'on' ? 1 : 0
], [
'param' => 'ssl',
'value' => $ssl == 'on' ? 1 : 0
], [
'param' => 'mysql_debug',
'value' => $mysql_debug == 'on' ? 1 : 0
], [
'param' => 'htaccess_cache',
'value' => $htaccess_cache == 'on' ? 1 : 0
], [
'param' => 'visits',
'value' => $visits
], [
'param' => 'links_structure',
'value' => $links_structure
], [
'param' => 'link_version',
'value' => $link_version
], [
'param' => 'widget_phone',
'value' => $widget_phone == 'on' ? 1 : 0
], [
'param' => 'update_key',
'value' => $update_key
]
]
);
\S::set_message( 'Ustawienia zostały zapisane' );
\S::delete_cache();
\S::htacces();
return true;
}
public static function settings_details()
{
global $mdb;
$results = $mdb -> select( 'pp_settings', '*', [ 'ORDER' => [ 'id' => 'ASC' ] ] );
if ( is_array( $results ) ) foreach ( $results as $row )
$settings[$row['param']] = $row['value'];
return $settings;
}
}
?>

View File

@@ -0,0 +1,88 @@
<?php
namespace admin\factory;
class Update
{
public static function update()
{
global $mdb, $settings;
\S::delete_session( 'new-version' );
$versions = file_get_contents( 'http://www.cmspro.project-dc.pl/updates/versions.php?key=' . $settings['update_key'] );
$versions = explode( PHP_EOL, $versions );
foreach ( $versions as $ver )
{
$ver = trim( $ver );
if ( (float)$ver > (float)\S::get_version() )
{
if ( strlen( $ver ) == 5 )
$dir = substr( $ver, 0, strlen( $ver ) - 2 ) . 0;
else
$dir = substr( $ver, 0, strlen( $ver ) - 1 ) . 0;
$file = file_get_contents( 'http://www.cmspro.project-dc.pl/updates/' . $dir . '/ver_' . $ver . '.zip' );
$dlHandler = fopen( 'update.zip' , 'w' );
if ( !fwrite( $dlHandler, $file ) )
return false;
fclose( $dlHandler );
if ( !file_exists( 'update.zip' ) )
return false;
else
{
/* aktualizacja bazy danych */
$sql = file_get_contents( 'http://www.cmspro.project-dc.pl/updates/' . $dir . '/ver_' . $ver . '_sql.txt' );
$sql = explode( PHP_EOL, $sql );
if ( is_array( $sql ) and !empty( $sql ) ) foreach ( $sql as $query )
{
if ( $sql )
$result = $mdb -> query( $query );
}
/* usuwanie zbędnych plików */
$lines = file_get_contents( 'http://www.cmspro.project-dc.pl/updates/' . $dir . '/ver_' . $ver . '_files.txt' );
$lines = explode( PHP_EOL, $lines );
if ( is_array( $lines ) ) foreach ( $lines as $line )
{
if ( strpos( $line, 'F: ' ) !== false )
{
$file = substr( $line, 3, strlen( $line ) );
if ( file_exists( $file ) )
unlink( $file );
}
if ( strpos( $line, 'D: ' ) !== false )
{
$dir = substr( $line, 3, strlen( $line ) );
if ( is_dir( $dir ) )
\S::delete_dir( $dir );
}
}
/* wgrywanie nowych plików */
$file_name = 'update.zip';
$path = pathinfo( realpath( $file_name ), PATHINFO_DIRNAME );
$path = substr( $path, 0, strlen( $path ) - 5 );
$zip = new \ZipArchive;
$res = $zip -> open( $file_name );
if ( $res === TRUE )
{
$zip -> extractTo( $path );
$zip -> close();
unlink( $file_name );
}
$updateThis = fopen( '../libraries/version.ini', 'w' );
fwrite( $updateThis, $ver );
fclose( $updateThis );
return true;
}
}
}
}
}

View File

@@ -0,0 +1,185 @@
<?php
namespace admin\factory;
class Users
{
public static function user_delete( $user_id )
{
global $mdb;
return $mdb -> delete( 'pp_users', [ 'id' => (int)$user_id ] );
}
public static function user_details( $user_id )
{
global $mdb;
return $mdb -> get( 'pp_users', '*', [ 'id' => (int)$user_id ] );
}
public static function user_privileges( $user_id )
{
global $mdb;
return $mdb -> select( 'pp_users_privileges', '*', ['id_user' => (int)$user_id]);
}
public static function user_save( $user_id, $login, $status, $active_to, $password, $password_re, $admin, $privileges )
{
global $mdb, $lang;
$mdb -> delete( 'pp_users_privileges', [ 'id_user' => (int) $user_id ] );
if ( !$user_id )
{
if ( strlen( $password ) < 5 )
return $response = [ 'status' => 'error', 'msg' => 'Podane hasło jest zbyt krótkie.' ];
if ( $password != $password_re )
return $response = [ 'status' => 'error', 'msg' => 'Podane hasła są różne' ];
if ( $mdb -> insert( 'pp_users',
[
'login' => $login,
'status' => $status == 'on' ? 1 : 0,
'active_to' => $active_to == '' ? NULL : $active_to,
'admin' => $admin,
'password' => md5( $password ),
] ) )
$id_user = $mdb -> get( 'pp_users', 'id', [ 'ORDER' => [ 'id' => 'DESC' ] ] );
if ( is_array( $privileges ) )
{
foreach ( $privileges as $pri )
{
$mdb -> insert( 'pp_users_privileges',
[
'name' => $pri,
'id_user' => $id_user
] );
}
}
else
{
$mdb -> insert( 'pp_users_privileges',
[
'name' => $privileges,
'id_user' => $id_user
] );
}
return $response = [ 'status' => 'ok', 'msg' => 'Użytkownik został zapisany.' ];
}
else
{
if ( $password and strlen( $password ) < 5 )
return $response = [ 'status' => 'error', 'msg' => 'Podane hasło jest zbyt krótkie.' ];
if ( $password and $password != $password_re )
return $response = [ 'status' => 'error', 'msg' => 'Podane hasła są różne' ];
if ( $password )
$mdb -> update( 'pp_users', [
'password' => md5( $password )
], [
'id' => (int) $user_id
] );
$mdb -> update( 'pp_users', [
'login' => $login,
'admin' => $admin,
'status' => $status == 'on' ? 1 : 0,
'active_to' => $active_to == '' ? NULL : $active_to,
'error_logged_count' => 0
], [
'id' => (int) $user_id
] );
if ( is_array( $privileges ) )
{
foreach ( $privileges as $pri )
{
$mdb -> insert( 'pp_users_privileges', [
'name' => $pri,
'id_user' => $user_id
] );
}
}
else
{
$mdb -> insert( 'pp_users_privileges', [
'name' => $privileges,
'id_user' => $user_id
] );
}
return $response = [ 'status' => 'ok', 'msg' => 'Uzytkownik został zapisany.' ];
}
\S::delete_cache();
}
public static function check_login( $login, $user_id )
{
global $mdb;
if ( $mdb -> get( 'pp_users', 'login', [ 'AND' => [ 'login' => $login, 'id[!]' => (int)$user_id ] ] ) )
return $response = [ 'status' => 'error', 'msg' => 'Podany login jest już zajęty.' ];
return $response = [ 'status' => 'ok' ];
}
public static function logon( $login, $password )
{
global $mdb;
if ( !$mdb -> get( 'pp_users', '*', [ 'login' => $login ] ) )
return 0;
if ( !$mdb -> get( 'pp_users', '*', [ 'AND' => [ 'login' => $login, 'status' => 1, 'error_logged_count[<]' => 5 ] ] ) )
return -1;
if ( $mdb -> get( 'pp_users', '*', [
'AND' => [
'login' => $login, 'status' => 1, 'password' => md5( $password ),
'OR' => [ 'active_to[>=]' => date('Y-m-d'), 'active_to' => null ]
]
] ) )
{
$mdb -> update( 'pp_users', [ 'last_logged' => date( 'Y-m-d H:i:s' ), 'error_logged_count' => 0 ], [ 'login' => $login ] );
return 1;
}
else
{
$mdb -> update( 'pp_users', [ 'last_error_logged' => date( 'Y-m-d H:i:s' ), 'error_logged_count[+]' => 1 ], [ 'login' => $login ] );
if ( $mdb -> get( 'pp_users', 'error_logged_count', [ 'login' => $login ] ) >= 5 )
{
$mdb -> update( 'pp_users', [ 'status' => 0 ], [ 'login' => $login ] );
return -1;
}
}
return 0;
}
public static function details( $login )
{
global $mdb;
return $mdb -> get( 'pp_users', '*', [ 'login' => $login ] );
}
public static function check_privileges( $name, $user_id )
{
global $mdb;
if ( $user_id == 1 )
return true;
else
{
if ( !$privilages = \Cache::fetch( "check_privileges:$user_id:$name-tmp" ) )
{
$privilages = $mdb -> count( 'pp_users_privileges', [ 'AND' => ['name' => $name, 'id_user' => (int)$user_id ]]);
\Cache::store( "check_privileges:$user_id:$name", $privilages );
}
return $privilages;
}
}
}
?>

View File

@@ -0,0 +1,37 @@
<?php
namespace admin\view;
class Articles
{
public static function browse_list()
{
$tpl = new \Tpl;
return $tpl -> render( 'articles/articles-browse-list' );
}
public static function subpages_list( $pages, $article_pages, $parent_id = 0, $step = 1 )
{
$tpl = new \Tpl();
$tpl -> pages = $pages;
$tpl -> parent_id = $parent_id;
$tpl -> step = $step;
$tpl -> article_pages = $article_pages;
return $tpl -> render( 'articles/subpages-list' );
}
public static function articles_list()
{
$tpl = new \Tpl;
return $tpl -> render( 'articles/articles-list' );
}
public static function article_edit( $values )
{
$tpl = new \Tpl;
if ( is_array( $values ) ) foreach ( $values as $key => $val )
$tpl -> $key = $val;
return $tpl -> render( 'articles/article-edit' );
}
}
?>

View File

@@ -0,0 +1,11 @@
<?php
namespace admin\view;
class ArticlesArchive
{
public static function articles_list()
{
$tpl = new \Tpl;
return $tpl -> render( 'articles/articles-archive-list' );
}
}

View File

@@ -0,0 +1,12 @@
<?php
namespace admin\view;
class Backups {
public static function backups_list($backups) {
$tpl = new \Tpl;
$tpl -> backups = $backups;
return $tpl -> render ('backups/backup-list');
}
}

View File

@@ -0,0 +1,20 @@
<?php
namespace admin\view;
class Banners
{
public static function banners_list()
{
$tpl = new \Tpl;
return $tpl -> render( 'banners/banners-list' );
}
public static function banner_edit( $banner, $languages )
{
$tpl = new \Tpl;
$tpl -> banner = $banner;
$tpl -> languages = $languages;
return $tpl -> render( 'banners/banner-edit' );
}
}
?>

View File

@@ -0,0 +1,17 @@
<?php
namespace admin\view;
class Emails {
public static function emails_list()
{
$tpl = new \Tpl;
return $tpl -> render( 'emails/emails-list' );
}
public static function email_details( $email )
{
$tpl = new \Tpl;
$tpl -> email = $email;
return $tpl -> render( 'emails/email-details' );
}
}

View File

@@ -0,0 +1,12 @@
<?php
namespace admin\view;
class FileManager
{
public function filemanager()
{
$tpl = new \Tpl;
return $tpl -> render( 'filemanager/filemanager' );
}
}
?>

View File

@@ -0,0 +1,32 @@
<?
namespace admin\view;
class Languages
{
public static function translation_edit( $translation, $languages )
{
$tpl = new \Tpl;
$tpl -> languages = $languages;
$tpl -> translation = $translation;
return $tpl -> render( 'languages/translation-edit' );
}
public static function language_edit( $language, $order )
{
$tpl = new \Tpl;
$tpl -> language = $language;
$tpl -> order = $order;
return $tpl -> render( 'languages/language-edit' );
}
public static function translations_list()
{
$tpl = new \Tpl;
return $tpl -> render( 'languages/translations-list' );
}
public static function languages_list()
{
$tpl = new \Tpl;
return $tpl -> render( 'languages/languages-list' );
}
}
?>

View File

@@ -0,0 +1,29 @@
<?php
namespace admin\view;
class Layouts
{
public static function subpages_list( $pages, $layout_pages, $parent_id = null, $step = 1 )
{
$tpl = new \Tpl;
$tpl -> pages = $pages;
$tpl -> step = $step;
$tpl -> layout_pages = $layout_pages;
return $tpl -> render( 'layouts/subpages-list' );
}
public static function layout_edit( $layout, $menus )
{
$tpl = new \Tpl;
$tpl -> layout = $layout;
$tpl -> menus = $menus;
return $tpl -> render( 'layouts/layout-edit' );
}
public static function layouts_list()
{
$tpl = new \Tpl;
return $tpl -> render( 'layouts/layouts-list' );
}
}
?>

View File

@@ -0,0 +1,55 @@
<?php
namespace admin\view;
class Newsletter
{
public static function emails_list()
{
$tpl = new \Tpl;
return $tpl -> render( 'newsletter/emails-list' );
}
public static function preview( $articles, $settings, $template, $dates = '' )
{
$tpl = new \Tpl;
$tpl -> articles = $articles;
$tpl -> settings = $settings;
$tpl -> template = $template;
$tpl -> dates = $dates;
return $tpl -> render( 'newsletter/preview' );
}
public static function prepare( $templates )
{
$tpl = new \Tpl;
$tpl -> templates = $templates;
return $tpl -> render( 'newsletter/prepare' );
}
public static function settings( $settings )
{
$tpl = new \Tpl;
$tpl -> settings = $settings;
return $tpl -> render( 'newsletter/settings' );
}
public static function email_templates_user()
{
$tpl = new \Tpl;
return $tpl -> render( 'newsletter/email-templates-user' );
}
public static function email_templates_admin()
{
$tpl = new \Tpl;
return $tpl -> render( 'newsletter/email-templates-admin' );
}
public static function email_template_edit($template)
{
$tpl = new \Tpl;
$tpl -> email_template = $template;
return $tpl -> render( 'newsletter/email-template-edit' );
}
}

View File

@@ -0,0 +1,18 @@
<?php
namespace admin\view;
class Page {
public static function show()
{
global $user;
if ( !$user || !$user['admin'] )
return \admin\view\Users::login_form();
$tpl = new \Tpl;
$tpl -> content = \admin\Site::route();
return $tpl -> render( 'site/main-layout' );
}
}
?>

View 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 \Tpl();
$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 -> render( 'other/page-panel' );
}
}
?>

View File

@@ -0,0 +1,68 @@
<?
namespace admin\view;
class Pages
{
public static function subpages_browse_list( $pages, $parent_id = null, $step = 1 )
{
$tpl = new \Tpl();
$tpl -> pages = $pages;
$tpl -> parent_id = $parent_id;
$tpl -> step = $step;
return $tpl -> render( 'pages/subpages-browse-list' );
}
static public function browse_list( $menus, $modal = false )
{
return \Tpl::view( 'pages/pages-browse-list', [
'menus' => $menus,
'modal' => $modal
] );
}
public static function page_articles( $page_id, $articles )
{
$tpl = new \Tpl;
$tpl -> page_id = $page_id;
$tpl -> articles = $articles;
return $tpl -> render( 'pages/page-articles' );
}
public static function page_edit( $page, $parent_id, $menu_id, $menus, $layouts, $languages, $settings )
{
$tpl = new \Tpl;
$tpl -> menu_id = $menu_id;
$tpl -> parent_id = $parent_id;
$tpl -> menus = $menus;
$tpl -> page = $page;
$tpl -> layouts = $layouts;
$tpl -> languages = $languages;
$tpl -> settings = $settings;
return $tpl -> render( 'pages/page-edit' );
}
public static function menu_edit( $menu )
{
$tpl = new \Tpl;
$tpl -> menu = $menu;
return $tpl -> render( 'pages/menu-edit' );
}
public static function pages_list( $menus )
{
$tpl = new \Tpl;
$tpl -> menus = $menus;
return $tpl -> render( 'pages/pages-list' );
}
public static function subpages_list( $pages, $parent_id = null, $step = 1 )
{
$tpl = new \Tpl();
$tpl -> pages = $pages;
$tpl -> parent_id = $parent_id;
$tpl -> step = $step;
return $tpl -> render( 'pages/subpages-list' );
}
}
?>

View File

@@ -0,0 +1,20 @@
<?php
namespace admin\view;
class Scontainers
{
public static function container_edit( $container, $languages )
{
$tpl = new \Tpl;
$tpl -> container = $container;
$tpl -> languages = $languages;
return $tpl -> render( 'scontainers/container-edit' );
}
public static function containers_list()
{
$tpl = new \Tpl;
return $tpl -> render( 'scontainers/containers-list' );
}
}

View File

@@ -0,0 +1,17 @@
<?php
namespace admin\view;
class SeoAdditional
{
public static function element_edit( $element = '' )
{
$tpl = new \Tpl;
$tpl -> element = $element;
return $tpl -> render( 'seo-additional/element-edit' );
}
public static function main_view()
{
$tpl = new \Tpl;
return $tpl -> render( 'seo-additional/main-view' );
}
}

View File

@@ -0,0 +1,13 @@
<?
namespace admin\view;
class Settings
{
public static function view( $settings )
{
$tpl = new \Tpl;
$tpl -> settings = $settings;
return $tpl -> render( 'settings/settings' );
}
}
?>

View File

@@ -0,0 +1,13 @@
<?php
namespace admin\view;
class Update
{
public static function main_view()
{
$tpl = new \Tpl;
$tpl -> ver = \S::get_version();
$tpl -> new_ver = \S::get_new_version();
return $tpl -> render( 'update/main-view' );
}
}

View File

@@ -0,0 +1,26 @@
<?php
namespace admin\view;
class Users
{
public static function login_form()
{
$tpl = new \Tpl;
return $tpl -> render( 'site/unlogged-layout' );
}
public static function users_list()
{
$tpl = new \Tpl;
return $tpl -> render( 'users/users-list' );
}
public static function user_edit( $user, $privileges )
{
$tpl = new \Tpl;
$tpl -> user = $user;
$tpl -> privileges = $privileges;
return $tpl -> render( 'users/user-edit' );
}
}
?>

196
autoload/class.Article.php Normal file
View File

@@ -0,0 +1,196 @@
<?php
class Article implements \ArrayAccess
{
public function __construct( $article_id, $lang_id )
{
global $mdb;
$result = $mdb -> get( 'pp_articles', '*', [ 'id' => (int)$article_id ] );
if ( \S::is_array_fix( $result ) ) foreach ( $result as $key => $val )
$this -> $key = $val;
$results = $mdb -> select( 'pp_articles_langs', '*', [ 'AND' => [ 'article_id' => (int)$article_id, 'lang_id' => $lang_id ] ] );
if ( is_array( $results ) ) foreach ( $results as $row )
{
if ( $row['copy_from'] )
{
$results2 = $mdb -> select( 'pp_articles_langs', '*', [ 'AND' => [ 'article_id' => (int)$article_id, 'lang_id' => $row['copy_from'] ] ] );
if ( is_array( $results2 ) ) foreach ( $results2 as $row2 )
$this -> language = $row2;
}
else
$this -> language = $row;
preg_match_all( \front\view\Site::container_pattern, $this -> language['entry'], $container_list );
if ( is_array( $container_list[0] ) ) foreach( $container_list[0] as $container_list_tmp )
{
$container_list_tmp = explode( ':', $container_list_tmp );
$this -> language['entry'] = str_replace( '[KONTENER:' . $container_list_tmp[1] . ']', \front\view\Scontainers::scontainer( $container_list_tmp[1] ), $this -> language['entry'] );
}
preg_match_all( \front\view\Site::container_pattern, $this -> language['text'], $container_list );
if ( is_array( $container_list[0] ) ) foreach( $container_list[0] as $container_list_tmp )
{
$container_list_tmp = explode( ':', $container_list_tmp );
$this -> language['text'] = str_replace( '[KONTENER:' . $container_list_tmp[1] . ']', \front\view\Scontainers::scontainer( $container_list_tmp[1] ), $this -> language['text'] );
}
}
$this -> images = $mdb -> select( 'pp_articles_images', '*', [ 'article_id' => (int)$article_id, 'ORDER' => [ 'o' => 'ASC', 'id' => 'ASC' ] ] );
$this -> files = $mdb -> select( 'pp_articles_files', '*', [ 'article_id' => (int)$article_id ] );
$this -> pages = $mdb -> select( 'pp_articles_pages', 'page_id', [ 'article_id' => (int)$article_id ] );
$this -> tags = $mdb -> select( 'pp_tags', [ '[><]pp_articles_tags' => [ 'id' => 'tag_id' ] ], 'name', [ 'article_id' => (int)$article_id ] );
$results = $mdb -> select( 'pp_articles_additional_params', [ '[><]pp_articles_additional_values' => [ 'id' => 'param_id' ] ], [ 'name', 'value', 'language_id' ], [ 'article_id' => (int)$article_id ] );
if ( is_array( $results ) ) foreach ( $results as $row )
{
if ( !$row['language_id'] )
$params[ $row['name'] ] = $row['value'];
else
$params[ $row['name'] ][$row['language_id']] = $row['value'];
}
$this -> params = $params;
}
public function updateView()
{
global $mdb;
$mdb -> update( 'pp_articles', [ 'views[+]' => 1 ], [ 'id' => $this -> id ] );
}
static public function newsList( $articles )
{
return \Tpl::view( 'articles/news-list', [
'articles' => $articles
] );
}
// pobierz najczęściej wyświtlane artykuły
static public function getTopNews( $page_id, $limit = 6, $lang_id )
{
global $mdb;
if ( !$articles_id = \Cache::fetch( "getTopNews:$page_id:$limit:$lang_id" ) )
{
$articles_id = $mdb -> query( 'SELECT * FROM ( '
. 'SELECT '
. 'a.id, date_add, views, '
. '( CASE '
. 'WHEN copy_from IS NULL THEN title '
. 'WHEN copy_from IS NOT NULL THEN ( '
. 'SELECT '
. 'title '
. 'FROM '
. 'pp_articles_langs '
. 'WHERE '
. 'lang_id = al.copy_from AND article_id = a.id '
. ') '
. 'END ) AS title '
. 'FROM '
. 'pp_articles_pages AS ap '
. 'INNER JOIN pp_articles AS a ON a.id = ap.article_id '
. 'INNER JOIN pp_articles_langs AS al ON al.article_id = ap.article_id '
. 'WHERE '
. 'status = 1 AND page_id = ' . (int)$page_id . ' AND lang_id = \'' . $lang_id . '\' '
. ') AS q1 '
. 'WHERE '
. 'q1.title IS NOT NULL '
. 'ORDER BY '
. 'q1.views DESC '
. 'LIMIT '
. '0, ' . (int)$limit ) -> fetchAll( \PDO::FETCH_ASSOC );
\Cache::store( "getTopNews:$page_id:$limit:$lang_id", $articles_id );
}
if ( \S::is_array_fix( $articles_id ) ) foreach ( $articles_id as $article_tmp )
{
if ( !$article = \Cache::fetch( 'article:' . $article_tmp['id'] . ':' . $lang_id ) )
{
$article = new \Article( $article_tmp['id'], $lang_id );
\Cache::store( 'article:' . $article_tmp['id'] . ':' . $lang_id, $article );
}
$articles[] = $article;
}
return $articles;
}
static public function getNews( $page_id, $limit = 6, $lang_id )
{
global $mdb;
if ( !$articles_id = \Cache::fetch( "getNews:$page_id:$limit:$lang_id" ) )
{
$articles_id = $mdb -> query( 'SELECT * FROM ( '
. 'SELECT '
. 'a.id, date_add, '
. '( CASE '
. 'WHEN copy_from IS NULL THEN title '
. 'WHEN copy_from IS NOT NULL THEN ( '
. 'SELECT '
. 'title '
. 'FROM '
. 'pp_articles_langs '
. 'WHERE '
. 'lang_id = al.copy_from AND article_id = a.id '
. ') '
. 'END ) AS title '
. 'FROM '
. 'pp_articles_pages AS ap '
. 'INNER JOIN pp_articles AS a ON a.id = ap.article_id '
. 'INNER JOIN pp_articles_langs AS al ON al.article_id = ap.article_id '
. 'WHERE '
. 'status = 1 AND page_id = ' . (int)$page_id . ' AND lang_id = \'' . $lang_id . '\' '
. ') AS q1 '
. 'WHERE '
. 'q1.title IS NOT NULL '
. 'ORDER BY '
. 'q1.date_add DESC '
. 'LIMIT '
. '0, ' . (int)$limit ) -> fetchAll( \PDO::FETCH_ASSOC );
\Cache::store( "getNews:$page_id:$limit:$lang_id", $articles_id );
}
if ( \S::is_array_fix( $articles_id ) ) foreach ( $articles_id as $article_tmp )
{
if ( !$article = \Cache::fetch( 'article:' . $article_tmp['id'] . ':' . $lang_id ) )
{
$article = new \Article( $article_tmp['id'], $lang_id );
\Cache::store( 'article:' . $article_tmp['id'] . ':' . $lang_id, $article );
}
$articles[] = $article;
}
return $articles;
}
public function __get( $variable )
{
if ( array_key_exists( $variable, $this -> data ) )
return $this -> $variable;
}
public function __set( $variable, $value )
{
$this -> $variable = $value;
}
public function offsetExists( $offset )
{
return isset( $this -> $offset );
}
public function offsetGet( $offset )
{
return $this -> $offset;
}
public function offsetSet( $offset, $value )
{
$this -> $offset = $value;
}
public function offsetUnset( $offset )
{
unset( $this -> $offset );
}
}

46
autoload/class.Cache.php Normal file
View File

@@ -0,0 +1,46 @@
<?php
class Cache
{
public static function store( $key, $data, $ttl = 86400 )
{
file_put_contents( self::get_file_name( $key ), gzdeflate( serialize( array( time() + $ttl, $data ) ) ) );
}
private static function get_file_name( $key )
{
$md5 = md5( $key );
$dir = 'temp/' . $md5[0] . '/' . $md5[1] . '/';
if ( !is_dir( $dir ) )
mkdir( $dir , 0755 , true );
return $dir . 's_cache_' . $md5;
}
public static function fetch( $key )
{
$filename = self::get_file_name( $key );
if ( !file_exists( $filename ) || !is_readable( $filename ) )
return false;
$data = gzinflate( 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];
}
}
?>

91
autoload/class.Html.php Normal file
View File

@@ -0,0 +1,91 @@
<?php
class Html
{
public static function form_text( array $params = array() )
{
$tpl = new \Tpl;
$tpl -> params = $params;
return $tpl -> render( 'html/form-text' );
}
public static function input_switch( array $params = array() )
{
$tpl = new \Tpl;
$tpl -> params = $params;
return $tpl -> render( 'html/input-switch' );
}
public static function select( array $params = array() )
{
$tpl = new \Tpl;
$tpl -> params = $params;
return $tpl -> render( 'html/select' );
}
public static function textarea( array $params = array() )
{
$defaults = array(
'rows' => 4,
);
$params = array_merge( $defaults, $params );
$tpl = new \Tpl;
$tpl -> params = $params;
return $tpl -> render( 'html/textarea' );
}
public static function input_icon( array $params = array() )
{
$defaults = array(
'type' => 'text',
);
$params = array_merge( $defaults, $params );
$tpl = new \Tpl;
$tpl -> params = $params;
return $tpl -> render( 'html/input-icon' );
}
public static function input( array $params = array() )
{
$defaults = array(
'type' => 'text',
);
$params = array_merge( $defaults, $params );
$tpl = new \Tpl;
$tpl -> params = $params;
return $tpl -> render( 'html/input' );
}
public static function button( array $params = array() )
{
$defaults = array(
'class' => 'btn-sm btn-info',
);
$params = array_merge( $defaults, $params );
$tpl = new \Tpl;
$tpl -> params = $params;
return $tpl -> render( 'html/button' );
}
public static function panel( array $params = array() )
{
$defaults = array(
'title' => 'panel-title',
'class' => 'panel-primary',
'content' => 'panel-content'
);
$params = array_merge( $defaults, $params );
$tpl = new \Tpl;
$tpl -> params = $params;
return $tpl -> render( 'html/panel' );
}
}

312
autoload/class.Image.php Normal file
View File

@@ -0,0 +1,312 @@
<?php
class ImageManipulator
{
/**
* @var int
*/
protected $width;
/**
* @var int
*/
protected $height;
/**
* @var resource
*/
protected $image;
protected $img_src;
/**
* Image manipulator constructor
*
* @param string $file OPTIONAL Path to image file or image data as string
* @return void
*/
public function __construct($file = null)
{
if (null !== $file) {
if (is_file($file)) {
$this -> img_src = $file;
$this->setImageFile($file);
} else {
echo 'a'; exit;
$this->setImageString($file);
}
}
}
/**
* Set image resource from file
*
* @param string $file Path to image file
* @return ImageManipulator for a fluent interface
* @throws InvalidArgumentException
*/
public function setImageFile($file)
{
if (!(is_readable($file) && is_file($file))) {
throw new InvalidArgumentException("Image file $file is not readable");
}
if (is_resource($this->image)) {
imagedestroy($this->image);
}
list ($this->width, $this->height, $type) = getimagesize($file);
switch ($type) {
case IMAGETYPE_GIF :
$this->image = imagecreatefromgif($file);
break;
case IMAGETYPE_JPEG :
$this->image = imagecreatefromjpeg($file);
break;
case IMAGETYPE_PNG :
$this->image = imagecreatefrompng($file);
break;
default :
throw new InvalidArgumentException("Image type $type not supported");
}
return $this;
}
/**
* Set image resource from string data
*
* @param string $data
* @return ImageManipulator for a fluent interface
* @throws RuntimeException
*/
public function setImageString($data)
{
if (is_resource($this->image)) {
imagedestroy($this->image);
}
if (!$this->image = imagecreatefromstring($data)) {
throw new RuntimeException('Cannot create image from data string');
}
$this->width = imagesx($this->image);
$this->height = imagesy($this->image);
return $this;
}
/**
* Resamples the current image
*
* @param int $width New width
* @param int $height New height
* @param bool $constrainProportions Constrain current image proportions when resizing
* @return ImageManipulator for a fluent interface
* @throws RuntimeException
*/
public function resample( $width, $height, $constrainProportions = true )
{
if (!is_resource($this->image)) {
throw new RuntimeException('No image set');
}
if ($constrainProportions) {
if ($this->height >= $this->width) {
$width = round($height / $this->height * $this->width);
} else {
$height = round($width / $this->width * $this->height);
}
}
$temp = imagecreatetruecolor($width, $height);
imagecopyresampled($temp, $this->image, 0, 0, 0, 0, $width, $height, $this->width, $this->height);
if ( function_exists('exif_read_data') )
{
$exif = exif_read_data( $this -> img_src );
if ( $exif && isset($exif['Orientation']) )
{
$orientation = $exif['Orientation'];
if ( $orientation != 1 )
{
$deg = 0;
switch ($orientation)
{
case 3:
$deg = 180;
break;
case 6:
$deg = 270;
break;
case 8:
$deg = 90;
break;
}
if ( $deg )
$temp = imagerotate( $temp, $deg, 0 );
}
}
}
return $this->_replace($temp);
}
/**
* Enlarge canvas
*
* @param int $width Canvas width
* @param int $height Canvas height
* @param array $rgb RGB colour values
* @param int $xpos X-Position of image in new canvas, null for centre
* @param int $ypos Y-Position of image in new canvas, null for centre
* @return ImageManipulator for a fluent interface
* @throws RuntimeException
*/
public function enlargeCanvas($width, $height, array $rgb = array(), $xpos = null, $ypos = null)
{
if (!is_resource($this->image)) {
throw new RuntimeException('No image set');
}
$width = max($width, $this->width);
$height = max($height, $this->height);
$temp = imagecreatetruecolor($width, $height);
if (count($rgb) == 3) {
$bg = imagecolorallocate($temp, $rgb[0], $rgb[1], $rgb[2]);
imagefill($temp, 0, 0, $bg);
}
if (null === $xpos) {
$xpos = round(($width - $this->width) / 2);
}
if (null === $ypos) {
$ypos = round(($height - $this->height) / 2);
}
imagecopy($temp, $this->image, (int) $xpos, (int) $ypos, 0, 0, $this->width, $this->height);
return $this->_replace($temp);
}
/**
* Crop image
*
* @param int|array $x1 Top left x-coordinate of crop box or array of coordinates
* @param int $y1 Top left y-coordinate of crop box
* @param int $x2 Bottom right x-coordinate of crop box
* @param int $y2 Bottom right y-coordinate of crop box
* @return ImageManipulator for a fluent interface
* @throws RuntimeException
*/
public function crop($x1, $y1 = 0, $x2 = 0, $y2 = 0)
{
if (!is_resource($this->image)) {
throw new RuntimeException('No image set');
}
if (is_array($x1) && 4 == count($x1)) {
list($x1, $y1, $x2, $y2) = $x1;
}
$x1 = max($x1, 0);
$y1 = max($y1, 0);
$x2 = min($x2, $this->width);
$y2 = min($y2, $this->height);
$width = $x2 - $x1;
$height = $y2 - $y1;
$temp = imagecreatetruecolor($width, $height);
imagecopy($temp, $this->image, 0, 0, $x1, $y1, $width, $height);
return $this->_replace($temp);
}
/**
* Replace current image resource with a new one
*
* @param resource $res New image resource
* @return ImageManipulator for a fluent interface
* @throws UnexpectedValueException
*/
protected function _replace($res)
{
if (!is_resource($res)) {
throw new UnexpectedValueException('Invalid resource');
}
if (is_resource($this->image)) {
imagedestroy($this->image);
}
$this->image = $res;
$this->width = imagesx($res);
$this->height = imagesy($res);
return $this;
}
/**
* Save current image to file
*
* @param string $fileName
* @return void
* @throws RuntimeException
*/
public function save($fileName, $type = IMAGETYPE_JPEG)
{
$dir = dirname($fileName);
if (!is_dir($dir)) {
if (!mkdir($dir, 0755, true)) {
throw new RuntimeException('Error creating directory ' . $dir);
}
}
try {
switch ($type) {
case IMAGETYPE_GIF :
if (!imagegif($this->image, $fileName)) {
throw new RuntimeException;
}
break;
case IMAGETYPE_PNG :
if (!imagepng($this->image, $fileName)) {
throw new RuntimeException;
}
break;
case IMAGETYPE_JPEG :
default :
if (!imagejpeg($this->image, $fileName, 95)) {
throw new RuntimeException;
}
}
} catch (Exception $ex) {
throw new RuntimeException('Error saving image file to ' . $fileName);
}
}
/**
* Returns the GD image resource
*
* @return resource
*/
public function getResource()
{
return $this->image;
}
/**
* Get current image resource width
*
* @return int
*/
public function getWidth()
{
return $this->width;
}
/**
* Get current image height
*
* @return int
*/
public function getHeight()
{
return $this->height;
}
}

File diff suppressed because one or more lines are too long

9
autoload/class.Page.php Normal file
View File

@@ -0,0 +1,9 @@
<?php
class Page
{
// pobierz rodzaj sortowania
static public function getPageSort( $page_id )
{
}
}

1328
autoload/class.S.php Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,45 @@
<?php
class Scontainer implements \ArrayAccess
{
static public function updateByFrontEditor( $scontainer_id, $content, $lang_id )
{
global $mdb;
return $mdb -> update( 'pp_scontainers_langs', [
'text' => $content
], [
'AND' => [ 'container_id' => $scontainer_id, 'lang_id' => $lang_id ]
] );
}
public function __get( $variable )
{
if ( array_key_exists( $variable, $this -> data ) )
return $this -> $variable;
}
public function __set( $variable, $value )
{
$this -> $variable = $value;
}
public function offsetExists( $offset )
{
return isset( $this -> $offset );
}
public function offsetGet( $offset )
{
return $this -> $offset;
}
public function offsetSet( $offset, $value )
{
$this -> $offset = $value;
}
public function offsetUnset( $offset )
{
unset( $this -> $offset );
}
}

73
autoload/class.Tpl.php Normal file
View File

@@ -0,0 +1,73 @@
<?php
class Tpl
{
protected $dir = 'templates/';
protected $vars = array();
function __construct( $dir = null )
{
if ( $dir !== null )
$this -> dir = $dir;
}
public static function view( $file, $values = '' )
{
$tpl = new \Tpl;
if ( is_array( $values ) ) foreach ( $values as $key => $val )
$tpl -> $key = $val;
return $tpl -> render( $file );
}
public function secureHTML( $val )
{
$out = stripslashes( $val );
$out = str_replace( "'", "&#039;", $out );
$out = str_replace( '"', "&#34;", $out );
$out = str_replace( "<", "&lt;", $out );
$out = str_replace( ">", "&gt;", $out );
return $out;
}
public function render( $file )
{
if ( file_exists( 'templates_user/' . $file . '.php' ) )
{
ob_start();
include 'templates_user/' . $file . '.php';
$out = ob_get_contents();
ob_end_clean();
return $out;
}
else if ( file_exists( 'templates/' . $file . '.php' ) )
{
ob_start();
include 'templates/' . $file . '.php';
$out = ob_get_contents();
ob_end_clean();
return $out;
}
else if ( file_exists( $file . '.php' ) )
{
ob_start();
include $file . '.php';
$out = ob_get_contents();
ob_end_clean();
return $out;
}
else
return '<div class="alert alert-danger" role="alert">Nie znaleziono pliku widoku: <b>' . $this -> dir . $file . '.php</b>';
}
public function __set( $name, $value )
{
$this -> vars[ $name ] = $value;
}
public function __get( $name )
{
return $this -> vars[ $name ];
}
}

View File

@@ -0,0 +1,154 @@
<?php
/*
This PHP class is free software: you can redistribute it and/or modify
the code under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
However, the license header, copyright and author credits
must not be modified in any form and always be displayed.
This class is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
@author geoPlugin (gp_support@geoplugin.com)
@copyright Copyright geoPlugin (gp_support@geoplugin.com)
$version 1.01
This PHP class uses the PHP Webservice of http://www.geoplugin.com/ to geolocate IP addresses
Geographical location of the IP address (visitor) and locate currency (symbol, code and exchange rate) are returned.
See http://www.geoplugin.com/webservices/php for more specific details of this free service
*/
class geoPlugin {
//the geoPlugin server
var $host = 'http://www.geoplugin.net/php.gp?ip={IP}&base_currency={CURRENCY}';
//the default base currency
var $currency = 'USD';
//initiate the geoPlugin vars
var $ip = null;
var $city = null;
var $region = null;
var $areaCode = null;
var $dmaCode = null;
var $countryCode = null;
var $countryName = null;
var $continentCode = null;
var $latitude = null;
var $longitude = null;
var $currencyCode = null;
var $currencySymbol = null;
var $currencyConverter = null;
function geoPlugin() {
}
function locate($ip = null) {
global $_SERVER;
if ( is_null( $ip ) ) {
$ip = $_SERVER['REMOTE_ADDR'];
}
$host = str_replace( '{IP}', $ip, $this->host );
$host = str_replace( '{CURRENCY}', $this->currency, $host );
$data = array();
$response = $this->fetch($host);
$data = unserialize($response);
//set the geoPlugin vars
$this->ip = $ip;
$this->city = $data['geoplugin_city'];
$this->region = $data['geoplugin_region'];
$this->areaCode = $data['geoplugin_areaCode'];
$this->dmaCode = $data['geoplugin_dmaCode'];
$this->countryCode = $data['geoplugin_countryCode'];
$this->countryName = $data['geoplugin_countryName'];
$this->continentCode = $data['geoplugin_continentCode'];
$this->latitude = $data['geoplugin_latitude'];
$this->longitude = $data['geoplugin_longitude'];
$this->currencyCode = $data['geoplugin_currencyCode'];
$this->currencySymbol = $data['geoplugin_currencySymbol'];
$this->currencyConverter = $data['geoplugin_currencyConverter'];
}
function fetch($host) {
if ( function_exists('curl_init') ) {
//use cURL to fetch data
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $host);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, 'geoPlugin PHP Class v1.0');
$response = curl_exec($ch);
curl_close ($ch);
} else if ( ini_get('allow_url_fopen') ) {
//fall back to fopen()
$response = file_get_contents($host, 'r');
} else {
trigger_error ('geoPlugin class Error: Cannot retrieve data. Either compile PHP with cURL support or enable allow_url_fopen in php.ini ', E_USER_ERROR);
return;
}
return $response;
}
function convert($amount, $float=2, $symbol=true) {
//easily convert amounts to geolocated currency.
if ( !is_numeric($this->currencyConverter) || $this->currencyConverter == 0 ) {
trigger_error('geoPlugin class Notice: currencyConverter has no value.', E_USER_NOTICE);
return $amount;
}
if ( !is_numeric($amount) ) {
trigger_error ('geoPlugin class Warning: The amount passed to geoPlugin::convert is not numeric.', E_USER_WARNING);
return $amount;
}
if ( $symbol === true ) {
return $this->currencySymbol . round( ($amount * $this->currencyConverter), $float );
} else {
return round( ($amount * $this->currencyConverter), $float );
}
}
function nearby($radius=10, $limit=null) {
if ( !is_numeric($this->latitude) || !is_numeric($this->longitude) ) {
trigger_error ('geoPlugin class Warning: Incorrect latitude or longitude values.', E_USER_NOTICE);
return array( array() );
}
$host = "http://www.geoplugin.net/extras/nearby.gp?lat=" . $this->latitude . "&long=" . $this->longitude . "&radius={$radius}";
if ( is_numeric($limit) )
$host .= "&limit={$limit}";
return unserialize( $this->fetch($host) );
}
}
?>

View File

@@ -0,0 +1,76 @@
<?php
namespace front\controls;
class Articles
{
public static function pixieset_save_favorite_images( $hash )
{
return \front\factory\Articles::pixieset_save_favorite_images( $hash );
}
public static function pixieset_image_favorite( $image_id, $hash )
{
return \front\factory\Articles::pixieset_image_favorite( $image_id, $hash );
}
public static function images_download( $hash )
{
global $mdb;
$results = $mdb -> query( 'SELECT * FROM ('
. 'SELECT id, MD5( CONCAT( id, date_add ) ) AS hash FROM pp_articles ) AS q1'
. ' WHERE hash = \'' . $hash . '\'' ) -> fetchAll( \PDO::FETCH_ASSOC );
if ( is_array( $results ) and count( $results ) ) foreach ( $results as $row )
{
$zip = new \ZipArchive;
$tmp_file = 'temp/' . $hash . '.zip';
if ( file_exists( $tmp_file ) )
return $tmp_file;
if ( $zip -> open( $tmp_file, \ZipArchive::CREATE ) )
{
$results2 = $mdb -> select( 'pp_articles_images', 'src', [ 'article_id' => $row['id'] ] );
if ( is_array( $results2 ) and count( $results2 ) ) foreach ( $results2 as $row2 )
{
$file = substr( $row2, 1, strlen( $row2 ) );
$zip -> addFile( $file, basename( $file ) );
}
$zip -> close();
return $tmp_file;
}
}
}
public static function image()
{
global $mdb;
$results = $mdb -> query( 'SELECT * FROM ('
. 'SELECT id, src, MD5( CONCAT( id, src ) ) AS hash FROM pp_articles_images ) AS q1'
. ' WHERE hash = \'' . \S::get( 'hash' ) . '\'' ) -> fetchAll( \PDO::FETCH_ASSOC );
if ( is_array( $results ) and count( $results ) )
{
$file = substr( $results[0]['src'], 1, strlen( $results[0]['src'] ) );
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="' . basename( $file ) . '"');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize( $file ) );
flush();
readfile($file);
exit;
}
exit;
}
public static function article_unlock( $password, $article_id )
{
if ( $password == \front\factory\Articles::article_password( $article_id ) )
\S::set_session( 'article-' . $article_id . '-' . $password, true );
}
}

View File

@@ -0,0 +1,63 @@
<?php
namespace front\controls;
class AuditSEO
{
public static function semstorm()
{
echo json_encode( \front\factory\AuditSEO::semstorm( \S::get( 'url' ) ) );
exit;
}
public static function data08()
{
echo json_encode( \front\factory\AuditSEO::data08( \S::get( 'url' ) ) );
exit;
}
public static function data07()
{
echo json_encode( \front\factory\AuditSEO::data07( \S::get( 'url' ) ) );
exit;
}
public static function data06()
{
echo json_encode( \front\factory\AuditSEO::data06( \S::get( 'url' ) ) );
exit;
}
public static function data05()
{
echo json_encode( \front\factory\AuditSEO::data05( \S::get( 'url' ) ) );
exit;
}
public static function data04()
{
echo json_encode( \front\factory\AuditSEO::data04( \S::get( 'url' ) ) );
exit;
}
public static function data03()
{
echo json_encode( \front\factory\AuditSEO::data03( \S::get( 'url' ) ) );
exit;
}
public static function data02()
{
echo json_encode( \front\factory\AuditSEO::data02( \S::get( 'url' ) ) );
exit;
}
public static function data01()
{
echo json_encode( \front\factory\AuditSEO::data01( \S::get( 'url' ) ) );
exit;
}
public static function main_view()
{
return \Tpl::view( 'audit-seo/main-view' );
}
}

View File

@@ -0,0 +1,38 @@
<?php
namespace front\controls;
class Newsletter
{
public static function signin()
{
$result = [ 'status' => 'bad' ];
if ( \front\factory\Newsletter::newsletter_signin( \S::get( 'email' ) ) )
$result = [ 'status' => 'ok' ];
echo json_encode( $result );
exit;
}
public static function confirm()
{
global $lang;
if ( \front\factory\Newsletter::newsletter_confirm( \S::get( 'hash' ) ) )
\S::alert( $lang['email-zostal-dodany-do-listy-newsletter'] );
header( 'Location: /' );
exit;
}
public static function unsubscribe()
{
global $lang;
if ( \front\factory\Newsletter::newsletter_unsubscribe( \S::get( 'hash' ) ) )
\S::alert( $lang['email-zostal-usuniety-z-listy-newsletter'] );
header( 'Location: /' );
exit;
}
}

View File

@@ -0,0 +1,122 @@
<?php
namespace front\controls;
class Site
{
public static function route()
{
global $page, $lang_id;
if ( \S::get( 'search' ) )
{
if ( $_POST['search_txt'] )
{
\S::set_session( 'search_txt', \S::get( 'search_txt' ) );
header( "Location: " . $_SERVER['REQUEST_URI'] );
exit;
}
return \front\view\Search::search_results(
\front\factory\Search::search_results( \S::get_session( 'search_txt' ), $lang_id )
);
}
if ( \S::get( 'tag' ) )
return \front\view\Articles::articles_list(
\front\factory\Articles::articles_by_tags( \S::get( 'tag' ), $lang_id )
);
if ( \S::get( 'article' ) )
{
$article = new \Article( \S::get( 'article' ), $lang_id );
if ( !\S::get_session( 'article-view-' . $article -> id ) )
{
$article -> updateView();
\S::set_session( 'article-view-' . $article -> id, true );
}
if ( $article['password'] and !\S::get_session( 'article-' . $article['id'] . '-' . $article['password'] ) )
return \front\view\Articles::password_view( [ 'article' => $article ] );
else
return \front\view\Articles::article( [ 'article' => $article ] );
}
if ( $page['page_type'] !== null )
{
switch ( $page['page_type'] )
{
/* pełne artykuły */
case 0:
return \front\view\Articles::full_articles_list( $page, $lang_id, \S::get( 'bs' ) );
break;
/* wprowadzenia */
case 1:
return \front\view\Articles::entry_articles_list( $page, $lang_id, \S::get( 'bs' ) );
break;
/* miniaturki */
case 2:
return \front\view\Articles::miniature_articles_list( $page, $lang_id, \S::get( 'bs' ) );
break;
/* strona kontaktu */
case 4:
$out = \front\view\Articles::full_articles_list( $page, $lang_id, \S::get( 'bs' ) );
$out .= \front\view\Site::contact();
return $out;
break;
}
}
if ( !\S::get( 'module' ) || !\S::get( 'action' ) )
return false;
$class = '\front\controls\\' . ucfirst( \S::get( 'module' ) );
$action = \S::get( 'action' );
if ( class_exists( $class ) and method_exists( new $class, $action ) )
return call_user_func_array( array( $class, $action ), array() );
}
public static function check_url_params()
{
global $lang, $config;
$a = \S::get( 'a' );
switch ( $a )
{
case 'page':
$page = \front\factory\Pages::page_details( \S::get( 'id' ) );
\S::set_session( 'page', $page );
break;
case 'change_language':
\S::set_session( 'current-lang', \S::get( 'id' ) );
header( 'Location: /' );
exit;
break;
case 'newsletter-sign':
if ( \front\factory\Newsletter::newsletter_signin( \S::get( 'email' ) ) )
\S::alert( 'Dziękujemy za zapisanie się do newslettera.' );
header( 'Location: ' . $_SERVER['REQUEST_URI'] );
exit;
break;
case 'newsletter-signout':
if ( \front\factory\Newsletter::newsletter_signout( \S::get( 'email' ) ) )
\S::alert( 'Twój adres email został usunięty z naszej bazy.' );
header( 'Location: ' . $_SERVER['REQUEST_URI'] );
exit;
break;
}
if ( \S::get( 'lang' ) )
\S::set_session( 'current-lang', \S::get( 'lang' ) );
if ( file_exists( 'modules/actions.php' ) )
include 'modules/actions.php';
}
}
?>

View File

@@ -0,0 +1,443 @@
<?php
namespace front\factory;
class Articles
{
static public function generateTableOfContents($content) {
$result = '';
$currentLevel = [];
preg_match_all('/<(h[1-6])([^>]*)>(.*?)<\/\1>/', $content, $matches, PREG_SET_ORDER);
$firstLevel = true;
foreach ($matches as $match) {
$level = intval(substr($match[1], 1));
while ($level < count($currentLevel)) {
$result .= '</li></ol>';
array_pop($currentLevel);
}
if ($level > count($currentLevel)) {
while ($level > count($currentLevel)) {
if (count($currentLevel) > 0 || $firstLevel) {
$result .= '<ol>';
$firstLevel = false;
}
array_push($currentLevel, 0);
}
$result .= '<li>';
} else {
$result .= '</li><li>';
}
$currentLevel[count($currentLevel) - 1]++;
preg_match('/\sid="([^"]*)"/', $match[2], $idMatches);
$id = isset($idMatches[1]) ? $idMatches[1] : '';
$result .= sprintf(
'<a href="#%s">%s</a>',
urlencode(strtolower($id)),
$match[3]
);
}
while (!empty($currentLevel)) {
$result .= '</li></ol>';
array_pop($currentLevel);
}
if (substr($result, 0, 8) === '<ol><ol>') {
return substr($result, 4, -5);
} else {
return $result;
}
}
// funkcja wywoływana dla każdego dopasowania do wyrażenia regularnego
static public function processHeaders( $matches )
{
$level = $matches[1];
$attrs = $matches[2];
$content = $matches[3];
$id_attr = 'id=';
$id_attr_pos = strpos($attrs, $id_attr);
if ($id_attr_pos === false) { // jeśli nie ma atrybutu id
$id = \S::seo( $content );
$attrs .= sprintf(' id="%s"', $id);
}
$html = sprintf( '<h%d%s>%s</h%d>', $level, $attrs, $content, $level );
return $html;
}
static public function generateHeadersIds( $text )
{
$pattern = '/<h([1-6])(.*?)>(.*?)<\/h\1>/si';
$text = preg_replace_callback( $pattern, array(__CLASS__, 'processHeaders'), $text );
return $text;
}
public static function pixieset_save_favorite_images( $hash )
{
global $mdb, $settings;
\S::delete_dir( 'temp/' );
$rows = $mdb -> select( 'pp_articles', [ 'id' ], [ 'hash' => $hash ] );
if ( is_array( $rows ) ) foreach ( $rows as $row ) {
$article = \front\factory\Articles::article_details( $row['id'], 'pl' );
$text = '<p>Witaj,<br />';
$text .= 'Użytkownik zatwierdził listę wybranych przez siebie zdjęć.<br />';
$text .= 'Poniżej znajdziesz nazwy wybranych zdjęć.</p>';
$text .= '<ul>';
if ( is_array( $article['images'] ) ) foreach ( $article['images'] as $image )
if ( $image['favorite'] )
$text .= '<li>' . basename( $image['src'] ) . '</li>';
$text .= '</ul>';
\S::send_email( $settings['contact_email'], 'Powiadomienie ze strony: ' . $_SERVER['SERVER_NAME'], $text );
return true;
}
return false;
}
public static function pixieset_image_favorite( $image_id, $hash )
{
global $mdb;
$rows = $mdb -> select( 'pp_articles', [ 'id' ], [ 'hash' => $hash ] );
if ( is_array( $rows ) ) foreach ( $rows as $row )
{
$status = $mdb -> get( 'pp_articles_images', 'favorite', [ 'AND' => [ 'article_id' => $row['id'], 'id' => $image_id ] ] );
$mdb -> update( 'pp_articles_images', [ 'favorite' => !$status ], [ 'AND' => [ 'article_id' => $row['id'], 'id' => $image_id ] ] );
\S::delete_dir( 'temp/' );
return !$status;
}
}
public static function article_password( $article_id )
{
global $mdb;
return $mdb -> get( 'pp_articles', 'password', [ 'id' => $article_id ] );
}
public static function articles_by_tags( $tag_id, $lang_id )
{
global $mdb;
if ( !$articles = \Cache::fetch( "articles_by_tags:$tag_id:$lang_id" ) )
{
$results = $mdb -> query( 'SELECT '
. 'pa.id '
. 'FROM '
. 'pp_articles AS pa '
. 'INNER JOIN pp_articles_tags AS pat ON pat.article_id = pa.id '
. 'WHERE '
. 'status = 1 '
. 'AND '
. 'tag_id = ' . (int)$tag_id ) -> fetchAll();
if ( is_array( $results ) and !empty( $results ) ) foreach ( $results as $row )
$articles[] = \front\factory\Articles::article_details( $row['id'], $lang_id );
\Cache::store( "articles_by_tags:$tag_id:$lang_id", $articles );
}
return $articles;
}
public static function tag_details( $tag_id )
{
global $mdb;
if ( !$tag = \Cache::fetch( "tag_details:$tag_id" ) )
{
$tag = $mdb -> get( 'pp_tags', '*', [ 'id' => (int)$tag_id ] );
\Cache::store( "tag_details:$tag_id", $tag );
}
return $tag;
}
public static function tags()
{
global $mdb;
if ( !$tags = \Cache::fetch( 'tags' ) )
{
$tags = $mdb -> query( 'SELECT '
. 'name, COUNT( tag_id ) AS c '
. 'FROM '
. 'pp_tags AS pt '
. 'INNER JOIN pp_articles_tags ON pt.id = tag_id '
. 'GROUP BY '
. 'tag_id '
. 'ORDER BY '
. 'c DESC '
. 'LIMIT 20'
) -> fetchAll();
\Cache::store( 'tags', $tags );
}
return $tags;
}
public static function articles_by_date( $month, $year, $lang_id )
{
global $mdb;
if ( !$articles = \Cache::fetch( "articles_by_date:$month:$year:$lang_id" ) )
{
$results = $mdb -> query( 'SELECT '
. 'id '
. 'FROM '
. 'pp_articles '
. 'WHERE '
. 'status = 1 '
. 'AND '
. '( '
. '( date_start BETWEEN \'' . date( 'Y-m-d', strtotime( '01-' . $month . '-' . $year ) ) . '\' AND \'' . date( 'Y-m-t', strtotime( '01-' . $month . '-' . $year ) ) . '\' ) '
. 'OR '
. '( date_end BETWEEN \'' . date( 'Y-m-d', strtotime( '01-' . $month . '-' . $year ) ) . '\' AND \'' . date( 'Y-m-t', strtotime( '01-' . $month . '-' . $year ) ) . '\' ) '
. 'OR '
. '( date_start <= \'' . date( 'Y-m-t', strtotime( '01-' . $month . '-' . $year ) ) . '\' AND date_end >= \'' . date( 'Y-m-t', strtotime( '01-' . $month . '-' . $year ) ) . '\' ) '
. ')' ) -> fetchAll();
if ( is_array( $results ) and !empty( $results ) ) foreach ( $results as $row )
$articles[] = \front\factory\Articles::article_details( $row['id'], $lang_id );
\Cache::store( "articles_by_date:$month:$year:$lang_id", $articles );
}
return $articles;
}
public static function news( $page_id, $limit = 6, $lang_id )
{
$sort = \front\factory\Pages::page_sort( $page_id );
$articles_id = \front\factory\Articles::artciles_id( (int)$page_id, $lang_id, $limit, $sort, 0 );
if ( is_array( $articles_id ) and !empty( $articles_id ) ) foreach ( $articles_id as $article_id )
$articles[] = \front\factory\Articles::article_details( $article_id, $lang_id );
return $articles;
}
public static function get_image( $article, $skip_entry = false )
{
if ( $article['language']['main_image'] )
{
if ( file_exists( substr( $article['language']['main_image'], 1, strlen( $article['language']['main_image'] ) ) ) )
return $article['language']['main_image'];
}
if ( !$skip_entry )
{
$dom = new \DOMDocument();
$dom -> loadHTML( mb_convert_encoding( $article['language']['entry'], 'HTML-ENTITIES', "UTF-8" ) );
$images = $dom -> getElementsByTagName( 'img' );
foreach ( $images as $img )
{
$src = $img -> getAttribute( 'src' );
if ( file_exists( substr( $src, 1, strlen( $src ) ) ) )
return $src;
}
}
$dom = new \DOMDocument();
$dom -> loadHTML( mb_convert_encoding( $article['language']['text'], 'HTML-ENTITIES', "UTF-8" ) );
$images = $dom -> getElementsByTagName( 'img' );
foreach ( $images as $img )
{
$src = $img -> getAttribute( 'src' );
if ( file_exists( substr( $src, 1, strlen( $src ) ) ) )
return $src;
}
if ( $article['images'] )
return $article['images'][0]['src'];
return false;
}
public static function article_noindex( $article_id )
{
global $mdb, $lang;
if ( !$noindex = \Cache::fetch( "article_noindex:$article_id:" . $lang[0] ) )
{
$noindex = $mdb -> get( 'pp_articles_langs', 'noindex', [ 'AND' => [ 'article_id' => (int)$article_id, 'lang_id' => $lang[0] ] ] );
\Cache::store( "article_noindex:$article_id:" . $lang[0], $noindex );
}
return $noindex;
}
public static function page_articles( $page, $lang_id, $bs )
{
$count = \front\factory\Articles::page_articles_count( $page['id'], $lang_id );
$ls = ceil( $count / $page['articles_limit'] );
if ( $bs < 1 )
$bs = 1;
else if ( $bs > $ls )
$bs = $ls;
$from = $page['articles_limit'] * ( $bs - 1 );
if ( $from < 0 )
$from = 0;
$results['articles'] = \front\factory\Articles::artciles_id( (int)$page['id'], $lang_id, (int)$page['articles_limit'], $page['sort_type'], $from );
$results['ls'] = $ls;
return $results;
}
public static function article_details( $article_id, $lang_id )
{
global $mdb;
if ( !$article = \Cache::fetch( "article_details:$lang_id:$article_id" ) )
{
$article = $mdb -> get( 'pp_articles', '*', [ 'id' => (int)$article_id ] );
$results = $mdb -> select( 'pp_articles_langs', '*', [ 'AND' => [ 'article_id' => (int)$article_id, 'lang_id' => $lang_id ] ] );
if ( is_array( $results ) ) foreach ( $results as $row )
{
if ( $row['copy_from'] )
{
$results2 = $mdb -> select( 'pp_articles_langs', '*', [ 'AND' => [ 'article_id' => (int)$article_id, 'lang_id' => $row['copy_from'] ] ] );
if ( is_array( $results2 ) ) foreach ( $results2 as $row2 )
$article['language'] = $row2;
}
else
$article['language'] = $row;
preg_match_all( \front\view\Site::container_pattern, $article['language']['entry'], $container_list );
if ( is_array( $container_list[0] ) ) foreach( $container_list[0] as $container_list_tmp )
{
$container_list_tmp = explode( ':', $container_list_tmp );
$article['language']['entry'] = str_replace( '[KONTENER:' . $container_list_tmp[1] . ']', \front\view\Scontainers::scontainer( $container_list_tmp[1] ), $article['language']['entry'] );
}
preg_match_all( \front\view\Site::container_pattern, $article['language']['text'], $container_list );
if ( is_array( $container_list[0] ) ) foreach( $container_list[0] as $container_list_tmp )
{
$container_list_tmp = explode( ':', $container_list_tmp );
$article['language']['text'] = str_replace( '[KONTENER:' . $container_list_tmp[1] . ']', \front\view\Scontainers::scontainer( $container_list_tmp[1] ), $article['language']['text'] );
}
}
$article['images'] = $mdb -> select( 'pp_articles_images', '*', [ 'article_id' => (int)$article_id, 'ORDER' => [ 'o' => 'ASC', 'id' => 'ASC' ] ] );
$article['files'] = $mdb -> select( 'pp_articles_files', '*', [ 'article_id' => (int)$article_id ] );
$article['pages'] = $mdb -> select( 'pp_articles_pages', 'page_id', [ 'article_id' => (int)$article_id ] );
$article['tags'] = $mdb -> select( 'pp_tags', [ '[><]pp_articles_tags' => [ 'id' => 'tag_id' ] ], 'name', [ 'article_id' => (int)$article_id ] );
$results = $mdb -> select( 'pp_articles_additional_params', [ '[><]pp_articles_additional_values' => [ 'id' => 'param_id' ] ], [ 'name', 'value', 'language_id' ], [ 'article_id' => (int)$article_id ] );
if ( is_array( $results ) ) foreach ( $results as $row )
{
if ( !$row['language_id'] )
$params[ $row['name'] ] = $row['value'];
else
$params[ $row['name'] ][$row['language_id']] = $row['value'];
}
$article['params'] = $params;
\Cache::store( "article_details:$lang_id:$article_id", $article );
}
return $article;
}
public static function artciles_id( $page_id, $lang_id, $articles_limit, $sort_type, $from )
{
global $mdb;
switch ( $sort_type )
{
case 0: $order = 'priority DESC, date_add ASC'; break;
case 1: $order = 'priority DESC, date_add DESC'; break;
case 2: $order = 'priority DESC, date_modify ASC'; break;
case 3: $order = 'priority DESC, date_modify DESC'; break;
case 4: $order = 'priority DESC, o ASC'; break;
case 5: $order = 'priority DESC, title ASC'; break;
case 6: $order = 'priority DESC, title DESC'; break;
default: $order = 'priority DESC, id ASC'; break;
}
if ( !$output = \Cache::fetch( "artciles_id:$page_id:$lang_id:$order:$from:$articles_limit" ) )
{
$results = $mdb -> query( 'SELECT * FROM ( '
. 'SELECT '
. 'a.id, date_modify, date_add, o, priority, '
. '( CASE '
. 'WHEN copy_from IS NULL THEN title '
. 'WHEN copy_from IS NOT NULL THEN ( '
. 'SELECT '
. 'title '
. 'FROM '
. 'pp_articles_langs '
. 'WHERE '
. 'lang_id = al.copy_from AND article_id = a.id '
. ') '
. 'END ) AS title '
. 'FROM '
. 'pp_articles_pages AS ap '
. 'INNER JOIN pp_articles AS a ON a.id = ap.article_id '
. 'INNER JOIN pp_articles_langs AS al ON al.article_id = ap.article_id '
. 'WHERE '
. 'status = 1 AND page_id = ' . (int)$page_id . ' AND lang_id = \'' . $lang_id . '\' '
. ') AS q1 '
. 'WHERE '
. 'q1.title IS NOT NULL '
. 'ORDER BY '
. 'q1.' . $order . ' '
. 'LIMIT '
. (int)$from . ',' . (int)$articles_limit ) -> fetchAll();
if ( is_array( $results ) and !empty( $results ) ) foreach ( $results as $row )
$output[] = $row['id'];
\Cache::store( "artciles_id:$page_id:$lang_id:$order:$from:$articles_limit", $output );
}
return $output;
}
public static function page_articles_count( $page_id, $lang_id )
{
global $mdb;
if ( !$output = \Cache::fetch( "page_articles_count:$page_id:$lang_id" ) )
{
$results = $mdb -> query( 'SELECT COUNT(0) FROM ( '
. 'SELECT '
. 'a.id, '
. '( CASE '
. 'WHEN copy_from IS NULL THEN title '
. 'WHEN copy_from IS NOT NULL THEN ( '
. 'SELECT '
. 'title '
. 'FROM '
. 'pp_articles_langs '
. 'WHERE '
. 'lang_id = al.copy_from AND article_id = a.id '
. ') '
. 'END ) AS title '
. 'FROM '
. 'pp_articles_pages AS ap '
. 'INNER JOIN pp_articles AS a ON a.id = ap.article_id '
. 'INNER JOIN pp_articles_langs AS al ON al.article_id = ap.article_id '
. 'WHERE '
. 'status = 1 AND page_id = ' . (int)$page_id . ' AND lang_id = \'' . $lang_id . '\' '
. ') AS q1 '
. 'WHERE '
. 'q1.title IS NOT NULL' ) -> fetchAll();
$output = $results[0][0];
\Cache::store( "page_articles_count:$page_id:$lang_id", $output );
}
return $output;
}
}

View File

@@ -0,0 +1,765 @@
<?php
namespace front\factory;
class AuditSEO
{
public static $good_img = '<img src="/templates/audit-seo/good.svg" class="status">';
public static $bad_img = '<img src="/templates/audit-seo/bad.svg" class="status">';
public static function robots_allowed( $robots_txt, $useragent )
{
$agents = array( preg_quote( '*' ) );
if ( $useragent) $agents[] = preg_quote( $useragent );
$agents = implode( '|', $agents );
$robotstxt = @file( $robots_txt );
if ( empty( $robotstxt ) )
return true;
$rules = array();
$ruleApplies = false;
foreach ( $robotstxt as $line )
{
if ( !$line = trim( $line ) )
continue;
if ( preg_match('/^\s*User-agent: (.*)/i', $line, $match ) )
$ruleApplies = preg_match( "/($agents)/i", $match[1] );
if ( $ruleApplies && preg_match( '/^\s*Disallow:(.*)/i', $line, $regs ) )
{
if ( !$regs[1] )
return true;
$rules[] = preg_quote( trim( $regs[1] ), '/' );
}
}
foreach ( $rules as $rule )
{
if ( preg_match( "/^$rule/", $parsed['path'] ) )
return false;
}
return true;
}
public static function is_url_internal( $domain, $url )
{
$domain_host = parse_url( $domain, PHP_URL_HOST );
$url_host = parse_url( $url, PHP_URL_HOST );
if ( $domain_host == $url_host or empty( $url_host ) )
{
if ( $url != '/' and $url != '#' and strpos( $url, 'mailto:' ) === false and $url != '' and strpos( $url, 'tel:' ) === false )
return true;
}
return false;
}
public static function is_url_external( $domain, $url )
{
$domain_host = str_replace( 'www.', '', parse_url( $domain, PHP_URL_HOST ) );
$url_host = str_replace( 'www.', '', parse_url( $url, PHP_URL_HOST ) );
if ( $domain_host != $url_host and !empty( $url_host ) and !empty( $domain_host ) )
{
if ( $url != '/' and $url != '#' and strpos( $url, 'mailto:' ) === false and $url != '' and strpos( $url, 'tel:' ) === false )
return true;
}
return false;
}
public static function semstorm( $url )
{
if ( !$url )
return false;
$data = [ 'domains' => [ $url ] ];
$data_string = json_encode( $data );
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, 'http://api.semstorm.com/api-v3/explorer/explorer-keywords/position-distribution.json?services_token=ay_oMCvqro2DuTbG5EMayLUTYitOJC_Lf40gq2Rj_zE' );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $ch, CURLOPT_VERBOSE, 1 );
curl_setopt( $ch, CURLOPT_TIMEOUT, 60 );
curl_setopt( $ch, CURLOPT_HEADER, false );
curl_setopt( $ch, CURLOPT_POST, true );
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen( $data_string ) )
);
$response = curl_exec( $ch );
curl_close ( $ch );
echo $response;
exit;
}
public static function data08( $url )
{
global $mdb;
$data08['top3']['txt'] = 0;
$data08['top10']['txt'] = 0;
$data08['top50']['txt'] = 0;
$results = $mdb -> get( 'as_sites', [ 'semstorm' ], [ 'url' => $url ] );
if ( !$results['semstorm'] )
{
if ( strpos( $url, 'www.' ) === 0 )
$url = str_replace( 'www.', '', $url );
$data = [ 'domains' => [ $url ] ];
$data_string = json_encode( $data );
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, 'http://api.semstorm.com/api-v3/explorer/explorer-keywords/position-distribution.json?services_token=ay_oMCvqro2DuTbG5EMayLUTYitOJC_Lf40gq2Rj_zE' );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $ch, CURLOPT_VERBOSE, 1 );
curl_setopt( $ch, CURLOPT_TIMEOUT, 60 );
curl_setopt( $ch, CURLOPT_HEADER, false );
curl_setopt( $ch, CURLOPT_POST, true );
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string );
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen( $data_string ) )
);
$response = curl_exec( $ch );
curl_close ( $ch );
$mdb -> update( 'as_sites', [ 'semstorm' => $response ], [ 'url' => $url ] );
$results['semstorm'] = $response;
}
$data_tmp = json_decode( $results['semstorm'], true );
foreach ( $data_tmp['results'][$url] as $key => $val )
{
if ( $key <= 3 )
$data08['top3']['txt'] += $val;
if ( $key > 3 and $key <= 10 )
$data08['top10']['txt'] += $val;
if ( $key > 10 )
$data08['top50']['txt'] += $val;
}
return $data08;
}
public static function data07( $url )
{
global $mdb;
$results = $mdb -> get( 'as_sites', [ 'html', 'effective_url' ], [ 'url' => $url ] );
$data07['audit_links_inside']['count'] = 0;
$data07['audit_links_outside']['count'] = 0;
$dom = new \DOMDocument();
@$dom -> loadHTML( $results['html'] );
$links = @$dom -> getElementsByTagName( 'a' );
for ( $i = 0; $i < $links -> length; $i++ )
{
$link = $links -> item( $i );
$url_tmp = $link -> getAttribute( 'href' );
if ( self::is_url_internal( $results['effective_url'], $url_tmp ) )
{
$data07['audit_links_inside']['count']++;
$links_internal[] = $url_tmp;
}
if ( self::is_url_external( $results['effective_url'], $url_tmp ) )
{
$data07['audit_links_outside']['count']++;
$links_external[] = $url_tmp;
}
}
$data07['audit_links_inside']['txt'] = implode( '<br>', $links_internal );
$data07['audit_links_outside']['txt'] = implode( '<br>', $links_external );
return $data07;
}
public static function data06( $url )
{
global $mdb;
$results = $mdb -> get( 'as_sites', [ 'effective_url', 'html', 'flash', 'iframe', 'file_robots_txt', 'file_sitemap_xml', 'inline_css', 'doctype', 'html_language', 'w3c' ], [ 'url' => $url ] );
$data06['flash']['txt'] = $results['flash'] ? 'tak' : 'nie';
$data06['iframe']['txt'] = $results['iframe'] ? 'tak' : 'nie';
$data06['file_robots_txt']['txt'] = $results['file_robots_txt'] ? 'tak' : 'nie';
$data06['file_sitemap_xml']['txt'] = $results['file_sitemap_xml'] ? 'tak' : 'nie';
$data06['imgs_without_alt']['txt'] = implode( '<br/>', self::imgs_without_alt( $results['html'] ) );
$data06['inline_css']['txt'] = $results['inline_css'] ? 'tak' : 'nie';
$data06['doctype']['txt'] = $results['doctype'];
$data06['html_language']['txt'] = $results['html_language'];
if ( !$results['w3c'] )
{
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, 'https://validator.w3.org/nu/?doc=' . urlencode( $results['effective_url'] ) . '%2F&out=json' );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $ch, CURLOPT_VERBOSE, 1 );
curl_setopt( $ch, CURLOPT_TIMEOUT, 60 );
curl_setopt( $ch, CURLOPT_HEADER, true );
curl_setopt( $ch, CURLOPT_CAINFO, 'cacert.pem' );
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true );
curl_setopt( $ch, CURLOPT_HEADER, false );
curl_setopt( $ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.103 Safari/537.36' );
$response = curl_exec( $ch );
curl_close ( $ch );
$mdb -> update( 'as_sites', [ 'w3c' => $response ], [ 'url' => $url ] );
$w3c = json_decode( $response, true );
}
else
{
$w3c = json_decode( $results['w3c'], true );
}
$data06['w3c_validator']['txt'] = 0;
foreach ( $w3c['messages'] as $message ) {
if ( $message['type'] == 'error' )
$data06['w3c_validator']['txt']++;
}
return $data06;
}
public static function data05( $url )
{
global $mdb;
$results = $mdb -> get( 'as_sites', [
'effective_url',
'page_speed_insight_mobile'
], [
'url' => $url
] );
if ( !$results['page_speed_insight_mobile'] )
{
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, 'https://www.googleapis.com/pagespeedonline/v5/runPagespeed?url=' . $results['effective_url'] . '&category=performance&strategy=mobile' );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $ch, CURLOPT_VERBOSE, 1 );
curl_setopt( $ch, CURLOPT_TIMEOUT, 60 );
curl_setopt( $ch, CURLOPT_HEADER, true );
curl_setopt( $ch, CURLOPT_CAINFO, 'cacert.pem' );
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true );
curl_setopt( $ch, CURLOPT_HEADER, false );
curl_setopt( $ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.103 Safari/537.36' );
$response = curl_exec( $ch );
curl_close ( $ch );
$mdb -> update( 'as_sites', [ 'page_speed_insight_mobile' => $response ], [ 'url' => $url ] );
$page_speed_insight_mobile = json_decode( $response, true );
}
else
{
$page_speed_insight_mobile = json_decode( $results['page_speed_insight_mobile'], true );
}
$data05['psid']['txt'] = ( $page_speed_insight_mobile['lighthouseResult']['categories']['performance']['score'] * 100 ) . '/100';
$data05['psid']['score'] = $page_speed_insight_mobile['lighthouseResult']['categories']['performance']['score'] * 100;
return $data05;
}
public static function data04( $url )
{
global $mdb;
$results = $mdb -> get( 'as_sites', [
'effective_url',
'page_speed_insight_desktop'
], [
'url' => $url
] );
if ( !$results['page_speed_insight_desktop'] )
{
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, 'https://www.googleapis.com/pagespeedonline/v5/runPagespeed?url=' . $results['effective_url'] . '&category=performance&strategy=desktop' );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $ch, CURLOPT_VERBOSE, 1 );
curl_setopt( $ch, CURLOPT_TIMEOUT, 60 );
curl_setopt( $ch, CURLOPT_HEADER, true );
curl_setopt( $ch, CURLOPT_CAINFO, 'cacert.pem' );
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true );
curl_setopt( $ch, CURLOPT_HEADER, false );
curl_setopt( $ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.103 Safari/537.36' );
$response = curl_exec( $ch );
curl_close ( $ch );
$mdb -> update( 'as_sites', [ 'page_speed_insight_desktop' => $response ], [ 'url' => $url ] );
$page_speed_insight_desktop = json_decode( $response, true );
}
else
{
$page_speed_insight_desktop = json_decode( $results['page_speed_insight_desktop'], true );
}
$data04['psid']['txt'] = ( $page_speed_insight_desktop['lighthouseResult']['categories']['performance']['score'] * 100 ) . '/100';
$data04['psid']['score'] = $page_speed_insight_desktop['lighthouseResult']['categories']['performance']['score'] * 100;
$data04['site_size']['txt'] = round( $page_speed_insight_desktop['lighthouseResult']['audits']['total-byte-weight']['numericValue'] / 1024 ) . ' KB';
$data04['site_http']['txt'] = $page_speed_insight_desktop['lighthouseResult']['audits']['network-requests']['numericValue'];
return $data04;
}
public static function data03( $url )
{
global $mdb;
$results = $mdb -> get( 'as_sites', [ 'meta_title', 'meta_description', 'meta_keywords', 'code_length', 'text_length', 'words_count',
'h1_count', 'h2_count', 'h3_count', 'h4_count', 'h5_count', 'h6_count'
], [
'url' => $url
] );
$data03['meta_title']['txt'] = $results['meta_title'];
$data03['meta_title']['signs'] = strlen( $results['meta_title'] );
$data03['meta_description']['txt'] = $results['meta_description'];
$data03['meta_description']['signs'] = strlen( $results['meta_description'] );
$data03['meta_keywords']['txt'] = $results['meta_keywords'] != '' ? $results['meta_keywords'] : 'brak';
$data03['code_to_text_ratio']['txt'] = round( ( $results['text_length'] / ( $results['text_length'] + $results['code_length'] ) * 100 ), 0 );
$data03['words_count']['txt'] = $results['words_count'];
$data03['headers']['h1_count']['txt'] = $results['h1_count'];
$data03['headers']['h2_count']['txt'] = $results['h2_count'];
$data03['headers']['h3_count']['txt'] = $results['h3_count'];
$data03['headers']['h4_count']['txt'] = $results['h4_count'];
$data03['headers']['h5_count']['txt'] = $results['h5_count'];
$data03['headers']['h6_count']['txt'] = $results['h6_count'];
return $data03;
}
public static function data02( $url )
{
global $mdb;
$results = $mdb -> get( 'as_sites', [ 'meta_robots', 'robots_txt', 'redirect_www', 'https' ], [ 'url' => $url ] );
$data02['meta_robots']['txt'] = strpos( $results['meta_robots'], 'index' ) !== false ? 'tak' : 'nie';
$data02['meta_robots']['img'] = strpos( $results['meta_robots'], 'index' ) !== false ? self::$good_img : self::$bad_img;
$robots_txt = self::robots_allowed( $data02['robots_txt'], 'GoogleBot' );
$data02['robots_txt']['txt'] = $robots_txt ? 'tak' : 'nie';
$data02['robots_txt']['img'] = $robots_txt ? self::$good_img : self::$bad_img;
$data02['redirect_www']['txt'] = $results['redirect_www'] ? 'tak' : 'nie';
$data02['redirect_www']['img'] = $results['redirect_www'] ? self::$good_img : self::$bad_img;
$data02['https']['txt'] = $results['https'] ? 'tak' : 'nie';
$data02['https']['img'] = $results['https'] ? self::$good_img : self::$bad_img;
return $data02;
}
public static function data01( $url )
{
global $mdb;
$data01 = $mdb -> get( 'as_sites', [
'effective_url',
'ip',
'location',
'favicon',
'cms'
], [
'url' => $url
] );
$url_tmp = parse_url( $data01['effective_url'] );
$location = json_decode( $data01['location'] );
$data01['domain']['txt'] = $url_tmp['host'];
$data01['location'] = $location -> country;
$data01['favicon'] = $data01['favicon'] != null ? 'tak' : 'nie';
$data01['cms'] = $data01['cms'] != null ? $data01['cms'] : 'nieznany';
return $data01;
}
public static function imgs_without_alt( $html )
{
$dom = new \DOMDocument();
@$dom -> loadHTML( $html );
$images = $dom -> getElementsByTagName( 'img' );
$cms = '';
for ( $i = 0; $i < $images -> length; $i++ )
{
$img = $images -> item( $i );
if ( $img -> getAttribute( 'alt' ) == '' )
$imgs_output[] = $img -> getAttribute( 'src' );
}
return $imgs_output;
}
public static function cms( $html )
{
$dom = new \DOMDocument();
@$dom -> loadHTML( $html );
$metas = $dom -> getElementsByTagName( 'meta' );
$cms = '';
for ( $i = 0; $i < $metas -> length; $i++ )
{
$meta = $metas -> item( $i );
if ( $meta -> getAttribute( 'name' ) == 'generator' )
$cms = $meta -> getAttribute( 'content' );
}
return $cms;
}
public static function meta_title( $html )
{
$dom = new \DOMDocument();
@$dom -> loadHTML( $html );
$metas = $dom -> getElementsByTagName( 'title' );
$meta_title = '';
$meta = $metas -> item( 0 );
$meta_title = $meta -> textContent;
return $meta_title;
}
public static function meta_description( $html )
{
$dom = new \DOMDocument();
@$dom -> loadHTML( $html );
$metas = $dom -> getElementsByTagName( 'meta' );
$meta_description = '';
for ( $i = 0; $i < $metas -> length; $i++ )
{
$meta = $metas -> item( $i );
if ( $meta -> getAttribute( 'name' ) == 'description' )
$meta_description = $meta -> getAttribute( 'content' );
}
return $meta_description;
}
public static function meta_keywords( $html )
{
$dom = new \DOMDocument();
@$dom -> loadHTML( $html );
$metas = $dom -> getElementsByTagName( 'meta' );
$meta_keywords = '';
for ( $i = 0; $i < $metas -> length; $i++ )
{
$meta = $metas -> item( $i );
if ( $meta -> getAttribute( 'name' ) == 'keywords' )
$meta_keywords = $meta -> getAttribute( 'content' );
}
return $meta_keywords;
}
public static function meta_robots( $html )
{
$dom = new \DOMDocument();
@$dom -> loadHTML( $html );
$metas = $dom -> getElementsByTagName( 'meta' );
$meta_robots = '';
for ( $i = 0; $i < $metas -> length; $i++ )
{
$meta = $metas -> item( $i );
if ( $meta -> getAttribute( 'name' ) == 'robots' || $meta -> getAttribute( 'name' ) == 'googlebot' )
$meta_robots = $meta -> getAttribute( 'content' );
}
return $meta_robots;
}
public static function header_count( $html, $header = 'h1' )
{
$dom = new \DOMDocument();
@$dom -> loadHTML( $html );
$headers = $dom -> getElementsByTagName( $header );
return $headers -> length;
}
public static function favicon( $html )
{
$dom = new \DOMDocument();
@$dom -> loadHTML( $html );
$links = $dom -> getElementsByTagName( 'link' );
$favicon = '';
for ( $i = 0; $i < $links -> length; $i++ )
{
$link = $links -> item( $i );
if ( $link -> getAttribute( 'rel' ) == 'icon' || $link -> getAttribute( 'rel' ) == "Shortcut Icon" || $link -> getAttribute( 'rel' ) == "shortcut icon" )
$favicon = $link -> getAttribute( 'href' );
}
return $favicon;
}
public static function flash_check( $html )
{
if ( strpos( $html, 'Get Adobe Flash player' ) !== false )
return true;
return false;
}
public static function iframe_check( $html )
{
$dom = new \DOMDocument();
@$dom -> loadHTML( $html );
$iframes = $dom -> getElementsByTagName( 'iframe' );
if ( $iframes -> length )
return true;
return false;
}
public static function doctype( $html ) {
if ( strpos( $html, 'HTML 4.01 Frameset//EN' ) !== false )
return 'HTML 4.01 Frameset';
elseif ( strpos( $html, 'HTML 4.01 Transitional//EN' ) !== false )
return 'HTML 4.01 Transitional';
elseif ( strpos( $html, 'HTML 4.01//EN' ) !== false )
return 'HTML 4.01 Strict';
else
return 'HTML 5';
}
public static function html_language( $html ) {
$dom = new \DOMDocument();
@$dom -> loadHTML( $html );
$htmls = $dom -> getElementsByTagName( 'html' );
for ( $i = 0; $i < $htmls -> length; $i++ ) {
$html = $htmls -> item( $i );
return $html -> getAttribute( 'lang' );
}
return false;
}
public static function inline_css( $html ) {
$dom = new \DOMDocument();
@$dom -> loadHTML( $html );
$spans = $dom -> getElementsByTagName( 'span' );
for ( $i = 0; $i < $spans -> length; $i++ ) {
$span = $spans -> item( $i );
if ( $span -> getAttribute( 'style' ) != '' )
return true;
}
$ps = $dom -> getElementsByTagName( 'p' );
for ( $i = 0; $i < $ps -> length; $i++ ) {
$p = $ps -> item( $i );
if ( $p -> getAttribute( 'style' ) != '' )
return true;
}
$divs = $dom -> getElementsByTagName( 'div' );
for ( $i = 0; $i < $divs -> length; $i++ ) {
$div = $divs -> item( $i );
if ( $div -> getAttribute( 'style' ) != '' )
return true;
}
return false;
}
public static function audit( $url )
{
global $mdb;
if ( !$url )
return false;
if ( strpos( $url, 'http://' ) === false and strpos( $url, 'https://' ) === false )
$url = 'http://' . $url;
$url_tmp = parse_url( $url );
$url = strip_tags( $url_tmp['host'] ) . $url_tmp['path'];
if ( substr( $url, -1, 1 ) == '/')
$url = substr( $url, 0, -1 );
if ( $mdb -> count( 'as_sites', [ 'url' => $url ] ) )
return $url;
else
{
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, $url );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $ch, CURLOPT_VERBOSE, 1 );
curl_setopt( $ch, CURLOPT_TIMEOUT, 60 );
curl_setopt( $ch, CURLOPT_HEADER, true );
curl_setopt( $ch, CURLOPT_CAINFO, 'cacert.pem' );
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true );
curl_setopt( $ch, CURLOPT_HEADER, false );
curl_setopt( $ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.103 Safari/537.36' );
$response = curl_exec( $ch );
$effective_url = curl_getinfo( $ch, CURLINFO_EFFECTIVE_URL );
$ip = curl_getinfo( $ch, CURLINFO_PRIMARY_IP );
$location = file_get_contents( "http://ipinfo.io/{$ip}/json" );
$favicon = self::favicon( $response );
$cms = self::cms( $response );
$meta_robots = self::meta_robots( $response );
$meta_title = self::meta_title( $response );
$meta_description = self::meta_description( $response );
$meta_keywords = self::meta_keywords( $response );
$h1_count = self::header_count( $response, 'h1' );
$h2_count = self::header_count( $response, 'h2' );
$h3_count = self::header_count( $response, 'h3' );
$h4_count = self::header_count( $response, 'h4' );
$h5_count = self::header_count( $response, 'h5' );
$h6_count = self::header_count( $response, 'h6' );
$flash = self::flash_check( $response );
$iframe = self::iframe_check( $response );
$inline_css = self::inline_css( $response );
$doctype = self::doctype( $response );
$html_language = self::html_language( $response );
$html_length = strlen( $response );
$text_length = strlen( strip_tags( $response ) );
$code_length = $html_length - $text_length;
$words_count = str_word_count( strip_tags( $response ) );
curl_close ( $ch );
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, $effective_url . '/robots.txt' );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $ch, CURLOPT_VERBOSE, 1 );
curl_setopt( $ch, CURLOPT_TIMEOUT, 60 );
curl_setopt( $ch, CURLOPT_HEADER, true );
curl_setopt( $ch, CURLOPT_CAINFO, 'cacert.pem' );
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true );
curl_setopt( $ch, CURLOPT_HEADER, false );
curl_setopt( $ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.103 Safari/537.36' );
$robots_txt = curl_exec( $ch );
if ( curl_getinfo( $ch, CURLINFO_HTTP_CODE ) == 200 )
$file_robots_txt = 1;
else
$file_robots_txt = 0;
curl_close ( $ch );
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, $effective_url . '/sitemap.xml' );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $ch, CURLOPT_VERBOSE, 1 );
curl_setopt( $ch, CURLOPT_TIMEOUT, 60 );
curl_setopt( $ch, CURLOPT_HEADER, true );
curl_setopt( $ch, CURLOPT_CAINFO, 'cacert.pem' );
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true );
curl_setopt( $ch, CURLOPT_HEADER, false );
curl_setopt( $ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.103 Safari/537.36' );
$sitemap_xml = curl_exec( $ch );
if ( curl_getinfo( $ch, CURLINFO_HTTP_CODE ) == 200 )
$file_sitemap_xml = 1;
else
$file_sitemap_xml = 0;
curl_close ( $ch );
$url_parse = parse_url( $effective_url );
$redirect_www = false;
if ( strpos( $effective_url, $url_parse['scheme'] . '://www.' ) !== false )
{
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, str_replace( $url_parse['scheme'] . '://www.', $url_parse['scheme'] . '://', $effective_url ) );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $ch, CURLOPT_VERBOSE, 1 );
curl_setopt( $ch, CURLOPT_TIMEOUT, 60 );
curl_setopt( $ch, CURLOPT_HEADER, true );
curl_setopt( $ch, CURLOPT_CAINFO, 'cacert.pem' );
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true );
curl_setopt( $ch, CURLOPT_HEADER, false );
curl_setopt( $ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.103 Safari/537.36' );
curl_exec( $ch );
$effective_url_tmp = curl_getinfo( $ch, CURLINFO_EFFECTIVE_URL );
curl_close ( $ch );
if ( $effective_url_tmp == $effective_url )
$redirect_www = true;
}
else
{
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, str_replace( $url_parse['scheme'] . '://', $url_parse['scheme'] . '://www.', $effective_url ) );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $ch, CURLOPT_VERBOSE, 1 );
curl_setopt( $ch, CURLOPT_TIMEOUT, 60 );
curl_setopt( $ch, CURLOPT_HEADER, true );
curl_setopt( $ch, CURLOPT_CAINFO, 'cacert.pem' );
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true );
curl_setopt( $ch, CURLOPT_HEADER, false );
curl_setopt( $ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.103 Safari/537.36' );
curl_exec( $ch );
$effective_url_tmp = curl_getinfo( $ch, CURLINFO_EFFECTIVE_URL );
curl_close ( $ch );
if ( $effective_url_tmp == $effective_url )
$redirect_www = true;
}
$mdb -> insert( 'as_sites', [
'url' => $url,
'html' => $response,
'effective_url' => $effective_url,
'ip' => $ip,
'location' => $location,
'favicon' => $favicon,
'cms' => $cms,
'meta_robots' => $meta_robots,
'robots_txt' => $robots_txt,
'redirect_www' => $redirect_www ? 1 : 0,
'https' => $url_parse['scheme'] == 'https' ? 1 : 0,
'meta_title' => $meta_title,
'meta_description' => $meta_description,
'meta_keywords' => $meta_keywords,
'code_length' => $code_length,
'text_length' => $text_length,
'words_count' => $words_count,
'h1_count' => $h1_count,
'h2_count' => $h2_count,
'h3_count' => $h3_count,
'h4_count' => $h4_count,
'h5_count' => $h5_count,
'h6_count' => $h6_count,
'flash' => $flash ? 1 : 0,
'iframe' => $iframe ? 1 : 0,
'file_robots_txt' => $file_robots_txt,
'file_sitemap_xml' => $file_sitemap_xml,
'inline_css' => $inline_css,
'doctype' => $doctype,
'html_language' => $html_language
] );
return $url;
}
}
}

View File

@@ -0,0 +1,22 @@
<?
namespace front\factory;
class Authors
{
// szczególy autora
static public function get_single_author( $id_author )
{
global $mdb;
if ( !$author = \Cache::fetch( "get_single_author:$id_author" ) )
{
$author = $mdb -> get( 'pp_authors', '*', [ 'id' => (int)$id_author ] );
$results = $mdb -> select( 'pp_authors_langs', '*', [ 'id_author' => (int)$id_author ] );
if ( is_array( $results ) ) foreach ( $results as $row )
$author['languages'][$row['id_lang']] = $row;
\Cache::store( "get_single_author:$id_author", $author );
}
return $author;
}
}

View File

@@ -0,0 +1,63 @@
<?php
namespace front\factory;
class Banners
{
public static function banners()
{
global $mdb, $lang;
if ( !$banners = \Cache::fetch( 'banners' ) )
{
$results = $mdb -> query( 'SELECT '
. 'id, name '
. 'FROM '
. 'pp_banners '
. 'WHERE '
. 'status = 1 '
. 'AND '
. '( date_start <= \'' . date( 'Y-m-d' ) . '\' OR date_start IS NULL ) '
. 'AND '
. '( date_end >= \'' . date( 'Y-m-d' ) . '\' OR date_end IS NULL ) '
. 'AND '
. 'home_page = 0' ) -> fetchAll();
if ( is_array( $results ) and !empty( $results ) ) foreach ( $results as $row )
{
$row['languages'] = $mdb -> get( 'pp_banners_langs', '*', [ 'AND' => [ 'id_banner' => (int)$row['id'], 'id_lang' => $lang[0] ] ] );
$banners[] = $row;
}
\Cache::store( 'banners', $banners );
}
return $banners;
}
public static function main_banner()
{
global $mdb, $lang;
if ( !$banner = \Cache::fetch( "main_banner:" . $lang[0] ) )
{
$banner = $mdb -> query( 'SELECT '
. '* '
. 'FROM '
. 'pp_banners '
. 'WHERE '
. 'status = 1 '
. 'AND '
. '( date_start <= \'' . date( 'Y-m-d' ) . '\' OR date_start IS NULL ) '
. 'AND '
. '( date_end >= \'' . date( 'Y-m-d' ) . '\' OR date_end IS NULL ) '
. 'AND '
. 'home_page = 1 '
. 'ORDER BY '
. 'date_end ASC '
. 'LIMIT 1' ) -> fetchAll();
$banner = $banner[0];
if ( $banner )
$banner['languages'] = $mdb -> get( 'pp_banners_langs', '*', [ 'AND' => [ 'id_banner' => (int)$banner['id'], 'id_lang' => $lang[0] ] ] );
\Cache::store( "main_banner:" . $lang[0], $banner );
}
return $banner;
}
}

View File

@@ -0,0 +1,58 @@
<?php
namespace front\factory;
class Languages
{
public static function default_domain()
{
global $mdb;
$results = $mdb -> query( 'SELECT domain FROM pp_langs WHERE status = 1 AND domain IS NOT NULL AND main_domain = 1' ) -> fetchAll();
return $default_domain = $results[0][0];
}
public static function default_language( $domain = '' )
{
global $mdb;
if ( !$default_language = \Cache::fetch( "default_language:$domain" ) )
{
if ( $domain )
$results = $mdb -> query( 'SELECT id FROM pp_langs WHERE status = 1 AND domain = \'' . $domain . '\' ORDER BY start DESC, o ASC LIMIT 1' ) -> fetchAll();
if ( !$domain or !\front\factory\Languages::default_domain() )
$results = $mdb -> query( 'SELECT id FROM pp_langs WHERE status = 1 AND domain IS NULL ORDER BY start DESC, o ASC LIMIT 1' ) -> fetchAll();
$default_language = $results[0][0];
\Cache::store( "default_language:$domain", $default_language );
}
return $default_language;
}
public static function active_languages()
{
global $mdb;
if ( !$active_languages = \Cache::fetch( 'active_languages' ) )
{
$active_languages = $mdb -> select( 'pp_langs', [ 'id', 'name', 'domain' ], [ 'status' => 1, 'ORDER' => [ 'o' => 'ASC' ] ] );
\Cache::store( 'active_languages', $active_languages );
}
return $active_languages;
}
public static function lang_translations( $language = 'pl' )
{
global $mdb;
if ( !$translations = \Cache::fetch( "lang_translations:$language" ) )
{
$translations[ '0' ] = $language;
$results = $mdb -> select( 'pp_langs_translations', [ 'text', $language ] );
if ( is_array( $results ) ) foreach ( $results as $row )
$translations[ $row['text'] ] = $row[ $language ];
\Cache::store( "lang_translations:$language", $translations );
}
return $translations;
}
}

View File

@@ -0,0 +1,53 @@
<?php
namespace front\factory;
class Layouts
{
public static function layout_details( $layout_id )
{
global $mdb, $cache;
if ( !$layout = \Cache::fetch( "layout_details:$layout_id" ) )
{
$layout = $mdb -> get( 'pp_layouts', '*', [ 'id' => (int)$layout_id ] );
if ( !$layout )
$layout = $mdb -> get( 'pp_layouts', '*', [ 'status' => 1 ] );
\Cache::store( "layout_details:$layout_id", $layout );
}
return $layout;
}
public static function article_layout( $article_id )
{
global $mdb, $cache;
if ( !$layout = \Cache::fetch( "article_layout:$article_id" ) )
{
$layout = $mdb -> get( 'pp_layouts', [ '[><]pp_articles' => [ 'id' => 'layout_id' ] ], '*', [ 'pp_articles.id' => (int)$article_id ] );
if ( !$layout )
$layout = $mdb -> get( 'pp_layouts', '*', [ 'status' => 1 ] );
\Cache::store( "article_layout:$article_id", $layout );
}
return $layout;
}
public static function active_layout( $page_id )
{
global $mdb, $cache;
if ( !$layout = \Cache::fetch( "active_layouts:$page_id" ) )
{
$layout = $mdb -> get( 'pp_layouts', [ '[><]pp_layouts_pages' => [ 'id' => 'layout_id' ] ], '*', [ 'page_id' => (int)$page_id ] );
if ( !$layout )
$layout = $mdb -> get( 'pp_layouts', '*', [ 'status' => 1 ] );
\Cache::store( "active_layouts:$page_id", $layout );
}
return $layout;
}
}

View File

@@ -0,0 +1,64 @@
<?php
namespace front\factory;
class Menu
{
public static function submenu_details( $page_id, $lang_id )
{
return self::subpages( $page_id, $lang_id );
}
static public function subpages( $page_id, $lang_id )
{
global $mdb;
if ( !$pages = \Cache::fetch( "subpages:$page_id:$lang_id" ) )
{
$results = $mdb -> select( 'pp_pages', [ 'id' ], [ 'AND' => [ 'status' => 1, 'parent_id' => $page_id ], 'ORDER' => [ 'o' => 'ASC' ] ] );
if ( is_array( $results ) ) foreach ( $results as $row )
{
$page = \front\factory\Pages::page_details( $row['id'] );
$page['pages'] = self::subpages( $row['id'], $lang_id );
$pages[] = $page;
}
\Cache::store( "subpages:$page_id", $pages );
}
return $pages;
}
public static function menu_details( $menu_id )
{
global $mdb, $lang_id;
if ( !$menu = \Cache::fetch( "menu_details:$menu_id:$lang_id" ) )
{
$menu = $mdb -> get( 'pp_menus', '*', [ 'id' => (int)$menu_id ] );
$menu['pages'] = self::menu_pages( $menu_id );
\Cache::store( "menu_details:$menu_id:$lang_id", $menu );
}
return $menu;
}
public static function menu_pages( $menu_id, $parent_id = null )
{
global $mdb, $lang_id;
if ( !$pages = \Cache::fetch( "menu_pages:$menu_id:$parent_id:$lang_id" ) )
{
$results = $mdb -> select( 'pp_pages', [ 'id' ], [ 'AND' => [ 'status' => 1, 'menu_id' => (int)$menu_id, 'parent_id' => $parent_id ], 'ORDER' => [ 'o' => 'ASC' ] ] );
if ( is_array( $results ) ) foreach ( $results as $row )
{
$page = \front\factory\Pages::page_details( $row['id'] );
$page['pages'] = self::menu_pages( $menu_id, $row['id'] );
$pages[] = $page;
}
\Cache::store( "menu_pages:$menu_id:$parent_id:$lang_id", $pages );
}
return $pages;
}
}

View File

@@ -0,0 +1,118 @@
<?php
namespace front\factory;
class Newsletter
{
public static function newsletter_unsubscribe( $hash )
{
global $mdb;
return $mdb -> update( 'pp_newsletter', [ 'status' => 0 ], [ 'hash' => $hash ] );
}
public static function newsletter_confirm( $hash )
{
global $mdb;
if ( !$id = $mdb -> get( 'pp_newsletter', 'id', [ 'AND' => [ 'hash' => $hash, 'status' => 0 ] ] ) )
return false;
else
$mdb -> update( 'pp_newsletter', [ 'status' => 1 ], [ 'id' => $id ] );
return true;
}
public static function newsletter_send( $limit = 5 )
{
global $mdb, $settings, $lang;
$results = $mdb -> query( 'SELECT * FROM pp_newsletter_send WHERE mailed = 0 ORDER BY id ASC LIMIT ' . $limit ) -> fetchAll();
if ( is_array( $results ) and !empty( $results ) )
{
foreach ( $results as $row )
{
$dates = explode( ' - ', $row['dates'] );
$text = \admin\view\Newsletter::preview(
\admin\factory\Articles::articles_by_date_add( $dates[0], $dates[1] ),
\admin\factory\Settings::settings_details(),
\admin\factory\Newsletter::email_template_detalis($row['id_template'])
);
if ( $settings['ssl'] ) $base = 'https'; else $base = 'http';
$link = $base . "://" . $_SERVER['SERVER_NAME'] . '/newsletter/unsubscribe/hash=' . \front\factory\Newsletter::get_hash( $row['email'] );
$text = str_replace( '[WYPISZ_SIE]', $link, $text );
$regex = "-(<img[^>]+src\s*=\s*['\"])(((?!'|\"|http(|s)://).)*)(['\"][^>]*>)-i";
$text = preg_replace( $regex, "$1" . $base . "://" . $_SERVER['SERVER_NAME'] . "$2$4", $text );
$regex = "-(<a[^>]+href\s*=\s*['\"])(((?!'|\"|http(|s)://).)*)(['\"][^>]*>)-i";
$text = preg_replace( $regex, "$1" . $base . "://" . $_SERVER['SERVER_NAME'] . "$2$4", $text );
\S::send_email( $row['email'], 'Newsletter ze strony: ' . $_SERVER['SERVER_NAME'], $text );
if ( $row['only_once'] )
$mdb -> update( 'pp_newsletter_send', [ 'mailed' => 1 ], [ 'id' => $row['id'] ] );
else
$mdb -> delete( 'pp_newsletter_send', [ 'id' => $row['id'] ] );
}
return true;
}
return false;
}
public static function get_hash( $email )
{
global $mdb;
return $mdb -> get( 'pp_newsletter', 'hash', [ 'email' => $email ] );
}
public static function newsletter_signin( $email )
{
global $mdb, $lang, $settings;
if ( !\S::email_check( $email ) )
return false;
if ( !$mdb -> get( 'pp_newsletter', 'id', [ 'email' => $email ] ) )
{
$hash = md5( time() . $email );
$text = $settings['newsletter_header'];
$text .= \front\factory\Newsletter::get_template( '#potwierdzenie-zapisu-do-newslettera' );
$text .= $settings['newsletter_footer_1'];
$settings['ssl'] ? $base = 'https' : $base = 'http';
$regex = "-(<img[^>]+src\s*=\s*['\"])(((?!'|\"|http://).)*)(['\"][^>]*>)-i";
$text = preg_replace( $regex, "$1" . $base . "://" . $_SERVER['SERVER_NAME'] . "$2$4", $text );
$regex = "-(<a[^>]+href\s*=\s*['\"])(((?!'|\"|http://).)*)(['\"][^>]*>)-i";
$text = preg_replace( $regex, "$1" . $base . "://" . $_SERVER['SERVER_NAME'] . "$2$4", $text );
$link = '/newsletter/confirm/hash=' . $hash;
$text = str_replace( '[LINK]', $link, $text );
$send = \S::send_email( $email, $lang['potwierdz-zapisanie-sie-do-newslettera'], $text );
$mdb -> insert( 'pp_newsletter', [ 'email' => $email, 'hash' => $hash, 'status' => 0 ] );
return true;
}
return false;
}
public static function get_template( $template_name )
{
global $mdb;
return $mdb -> get( 'pp_newsletter_templates', 'text', [ 'name' => $template_name ] );
}
public static function newsletter_signout( $email )
{
global $mdb;
if ( $mdb -> get( 'pp_newsletter', 'id', [ 'email' => $email ] ) )
return $mdb -> delete( 'pp_newsletter', [ 'email' => $email ] );
return false;
}
}

View File

@@ -0,0 +1,81 @@
<?php
namespace front\factory;
class Pages
{
public static function page_sort( $page_id )
{
global $mdb;
if ( !$sort = \Cache::fetch( "page_sort:$page_id" ) )
{
$sort = $mdb -> get( 'pp_pages', 'sort_type', [ 'id' => $page_id ] );
\Cache::store( "page_sort:$page_id", $sort );
}
return $sort;
}
public static function lang_url( $page_id, $lang_id_t, $domain = '', $default_domain = '' )
{
$page = self::page_details( $page_id, $lang_id_t );
$page['language']['seo_link'] ? $url = '/' . $page['language']['seo_link'] : $url = '/s-' . $page['id'] . '-' . \S::seo( $page['language']['title'] );
if ( $lang_id_t == \S::get_session( 'current-lang' ) and !$default_domain and $lang_id_t == \front\factory\Languages::default_language( $domain ) )
return $url;
if ( $domain and $lang_id_t != \S::get_session( 'current-lang' ) )
return 'http://' . $domain . $url;
if ( !$domain && $default_domain )
{
if ( $lang_id_t != \front\factory\Languages::default_language( $default_domain ) and $url != '#' )
$url = '/' . $lang_id_t . $url;
return 'http://' . $default_domain . $url;
}
if ( $lang_id_t != \front\factory\Languages::default_language( $domain ) and $url != '#' )
$url = '/' . $lang_id_t . $url;
return $url;
}
public static function page_details( $id = '', $lang_tmp = '' )
{
global $mdb, $lang_id;
$page_lang = $lang_id;
if ( !$id )
$id = self::main_page_id();
if ( $lang_tmp )
$page_lang = $lang_tmp;
if ( !$page = \Cache::fetch( "page_details:$page_lang:$id" ) )
{
$page = $mdb -> get( 'pp_pages', '*', [ 'id' => (int)$id ] );
$page['language'] = $mdb -> get( 'pp_pages_langs', '*', [ 'AND' => [ 'page_id' => (int)$id, 'lang_id' => $page_lang ] ] );
\Cache::store( "page_details:$page_lang:$id", $page );
}
return $page;
}
public static function main_page_id()
{
global $mdb;
if ( !$id = \Cache::fetch( 'main_page_id' ) )
{
$id = $mdb -> get( 'pp_pages', 'id', [ 'AND' => [ 'status' => 1, 'start' => 1 ] ] );
if ( !$id )
$id = $mdb -> get( 'pp_pages', 'id', [ 'status' => 1, 'ORDER' => [ 'menu_id' => 'ASC', 'o' => 'ASC' ], 'LIMIT' => 1 ] );
\Cache::store( 'main_page_id', $id );
}
return $id;
}
}

View File

@@ -0,0 +1,23 @@
<?php
namespace front\factory;
class Scontainers
{
public static function scontainer_details( $scontainer_id )
{
global $mdb, $lang;
if ( !$scontainer = \Cache::fetch( "scontainer_details:$scontainer_id:" . $lang[0] ) )
{
$scontainer = $mdb -> get( 'pp_scontainers', '*', [ 'id' => (int)$scontainer_id ] );
$results = $mdb -> select( 'pp_scontainers_langs', '*', [ 'AND' => [ 'container_id' => (int)$scontainer_id, 'lang_id' => $lang[0] ] ] );
if ( is_array( $results ) ) foreach ( $results as $row )
$scontainer['languages'] = $row;
\Cache::store( "scontainer_details:$scontainer_id:" . $lang[0], $scontainer );
}
return $scontainer;
}
}

View File

@@ -0,0 +1,74 @@
<?php
namespace front\factory;
class Search
{
public static function search_results( $search_txt, $lang_id )
{
global $mdb, $cache;
if ( strlen( $search_txt ) < 3 )
return false;
if ( !$articles = \Cache::fetch( "search_results:$search_txt:$lang_id" ) )
{
$results = $mdb -> query( 'SELECT * FROM ( '
. 'SELECT '
. 'a.id, '
. '( CASE '
. 'WHEN copy_from IS NULL THEN title '
. 'WHEN copy_from IS NOT NULL THEN ( '
. 'SELECT '
. 'title '
. 'FROM '
. 'pp_articles_langs '
. 'WHERE '
. 'lang_id = al.copy_from AND article_id = a.id '
. ') '
. 'END ) AS title, '
. '( CASE '
. 'WHEN copy_from IS NULL THEN entry '
. 'WHEN copy_from IS NOT NULL THEN ( '
. 'SELECT '
. 'entry '
. 'FROM '
. 'pp_articles_langs '
. 'WHERE '
. 'lang_id = al.copy_from AND article_id = a.id '
. ') '
. 'END ) AS entry, '
. '( CASE '
. 'WHEN copy_from IS NULL THEN text '
. 'WHEN copy_from IS NOT NULL THEN ( '
. 'SELECT '
. 'text '
. 'FROM '
. 'pp_articles_langs '
. 'WHERE '
. 'lang_id = al.copy_from AND article_id = a.id '
. ') '
. 'END ) AS text '
. 'FROM '
. 'pp_articles AS a '
. 'INNER JOIN pp_articles_langs AS al ON a.id = al.article_id '
. 'WHERE '
. 'status = 1 AND lang_id = \'' . $lang_id . '\' '
. ') AS q1 '
. 'WHERE '
. 'q1.title IS NOT NULL '
. 'AND '
. '( '
. 'LOWER( title ) LIKE \'%' . \S::escape( strtolower( $search_txt ) ) . '%\' '
. 'OR '
. 'LOWER( entry ) LIKE \'%' . \S::escape( strtolower( $search_txt ) ) . '%\' '
. 'OR '
. 'LOWER( text ) LIKE \'%' . \S::escape( strtolower( $search_txt ) ) . '%\' '
. ')' ) -> fetchAll();
if ( is_array( $results ) and !empty( $results ) ) foreach ( $results as $row )
$articles[] = \front\factory\Articles::article_details( $row['id'], $lang_id );
\Cache::store( "search_results:$search_txt:$lang_id", $articles );
}
return $articles;
}
}

View File

@@ -0,0 +1,10 @@
<?php
namespace front\factory;
class SeoAdditional
{
public static function seo_active()
{
global $mdb;
return $mdb -> select( 'pp_seo_additional', '*', [ 'status' => 1 ] );
}
}

View File

@@ -0,0 +1,27 @@
<?php
namespace front\factory;
class Settings
{
public static function settings_details()
{
global $mdb;
if ( !$settings = \Cache::fetch( 'settings_details' ) )
{
$results = $mdb -> select( 'pp_settings', '*' );
if ( is_array( $results ) ) foreach ( $results as $row )
$settings[ $row['param'] ] = $row['value'];
\Cache::store( 'settings_details', $settings );
}
return $settings;
}
public static function visit_counter()
{
global $mdb;
return $mdb -> get( 'pp_settings', 'value', [ 'param' => 'visits'] );
}
}

View File

@@ -0,0 +1,143 @@
<?php
namespace front\view;
class Articles
{
public static function password_view( $values )
{
$tpl = new \Tpl;
if ( is_array( $values ) ) foreach ( $values as $key => $val )
$tpl -> $key = $val;
return $tpl -> render( 'articles/password-view' );
}
public static function map( $settings, $map_counter )
{
$tpl = new \Tpl;
$tpl -> settings = $settings;
$tpl -> map_counter = $map_counter;
return $tpl -> render( 'articles/map' );
}
public static function tags_cloud()
{
global $settings;
if ( !$settings['tags'] )
return false;
$tpl = new \Tpl;
$tpl -> tags = \front\factory\Articles::tags();
return $tpl -> render( 'articles/tags-cloud' );
}
public static function news( $page_id, $articles )
{
$tpl = new \Tpl;
$tpl -> page_id = $page_id;
$tpl -> articles = $articles;
return $tpl -> render( 'articles/news' );
}
public static function articles_list( $articles )
{
$tpl = new \Tpl;
$tpl -> articles = $articles;
return $tpl -> render( 'articles/articles-list' );
}
public static function article( $values )
{
$tpl = new \Tpl;
if ( is_array( $values ) ) foreach ( $values as $key => $val )
$tpl -> $key = $val;
return $tpl -> render( 'articles/article' );
}
public static function article_full( $article_id, $lang_id )
{
$tpl = new \Tpl;
$tpl -> article = \front\factory\Articles::article_details( $article_id, $lang_id );
return $tpl -> render( 'articles/article-full' );
}
public static function miniature_articles_list( $page, $lang_id, $bs = 1 )
{
$results = \front\factory\Articles::page_articles( $page, $lang_id, $bs );
if ( is_array( $results['articles'] ) ) foreach ( $results['articles'] as $article )
$articles[] = \front\factory\Articles::article_details( $article, $lang_id );
$tpl = new \Tpl;
$tpl -> page_id = $page['id'];
$tpl -> articles = $articles;
$out .= $tpl -> render( 'articles/articles-miniatures' );
if ( $results['ls'] > 1 )
{
$tpl = new \Tpl;
$tpl -> ls = $results['ls'];
$tpl -> bs = $bs ? $bs : 1;
$tpl -> page = $page;
$out .= $tpl -> render( 'site/pager' );
}
return $out;
}
public static function entry_articles_list( $page, $lang_id, $bs = 1 )
{
global $page;
$results = \front\factory\Articles::page_articles( $page, $lang_id, $bs );
if ( is_array( $results['articles'] ) ) foreach ( $results['articles'] as $article )
$articles[] = \front\factory\Articles::article_details( $article, $lang_id );
$tpl = new \Tpl;
$tpl -> page_id = $page['id'];
$tpl -> articles = $articles;
$out .= $tpl -> render( 'articles/articles-entries' );
if ( $results['ls'] > 1 )
{
$tpl = new \Tpl;
$tpl -> ls = $results['ls'];
$tpl -> bs = $bs ? $bs : 1;
$tpl -> page = $page;
$out .= $tpl -> render( 'site/pager' );
}
return $out;
}
public static function full_articles_list( $page, $lang_id, $bs = 1 )
{
$results = \front\factory\Articles::page_articles( $page, $lang_id, $bs );
if ( is_array( $results['articles'] ) ) foreach ( $results['articles'] as $article )
{
$article_details = \front\factory\Articles::article_details( $article, $lang_id );
if ( $article_details['password'] and !\S::get_session( 'article-' . $article . '-' . $article_details['password'] ) )
$out .= \front\view\Articles::password_view( [ 'article' => $article ] );
else
{
$tpl = new \Tpl;
$tpl -> article = $article_details;
$out .= $tpl -> render( 'articles/article-full' );
}
}
if ( $results['ls'] > 1 )
{
$tpl = new \Tpl;
$tpl -> ls = $results['ls'];
$tpl -> bs = $bs ? $bs : 1;
$tpl -> page = $page;
$out .= $tpl -> render( 'site/pager' );
}
return $out;
}
}

View File

@@ -0,0 +1,35 @@
<?php
namespace front\view;
class Banners
{
public static function banners( $banners )
{
$tpl = new \Tpl;
$tpl -> banners = $banners;
return $tpl -> render( 'banner/banners' );
}
public static function main_banner( $banner )
{
if ( file_exists( 'templates/banner/draw.php' ) and !file_exists( 'templates/banner/main-banner.php' ) )
copy( 'templates/banner/draw.php', 'templates/banner/main-banner.php' );
if ( file_exists( 'templates/banner/draw.php' ) and file_exists( 'templates/banner/main-banner.php' ) )
unlink( 'templates/banner/draw.php' );
if ( file_exists( 'templates_user/banner/draw.php' ) and !file_exists( 'templates_user/banner/main-banner.php' ) )
copy( 'templates_user/banner/draw.php', 'templates_user/banner/main-banner.php' );
if ( file_exists( 'templates_user/banner/draw.php' ) and file_exists( 'templates_user/banner/main-banner.php' ) )
unlink( 'templates_user/banner/draw.php' );
if ( !\S::get_session( 'banner_close' ) && is_array( $banner ) )
{
$tpl = new \Tpl;
$tpl -> banner = $banner;
return $tpl -> render( 'banner/main-banner' );
}
}
}

View File

@@ -0,0 +1,13 @@
<?php
namespace front\view;
class Languages
{
public static function languages()
{
$tpl = new \Tpl;
$tpl -> languages = \front\factory\Languages::active_languages();
$tpl -> default_domain = \front\factory\Languages::default_domain();
return $tpl -> render( 'site/languages' );
}
}

View File

@@ -0,0 +1,42 @@
<?php
namespace front\view;
class Menu
{
public static function pages( $pages, $level = 0, $current_page = 0 )
{
$tpl = new \Tpl;
$tpl -> pages = $pages;
$tpl -> level = $level;
$tpl -> current_page = $current_page;
return $tpl -> render( 'menu/pages' );
}
public static function main_menu( $menu, $current_page )
{
$tpl = new \Tpl;
$tpl -> menu = $menu;
$tpl -> current_page = $current_page;
return $tpl -> render( 'menu/main-menu' );
}
public static function menu( $menu, $current_page )
{
$tpl = new \Tpl;
$tpl -> menu = $menu;
$tpl -> current_page = $current_page;
return $tpl -> render( 'menu/menu' );
}
public static function submenu( $pages, $current_page, $page_id, $level = 0 )
{
$tpl = new \Tpl;
$tpl -> page_id = $page_id;
$tpl -> pages = $pages;
$tpl -> current_page = $current_page;
$tpl -> level = $level;
return $tpl -> render( 'menu/submenu' );
}
}

View File

@@ -0,0 +1,11 @@
<?php
namespace front\view;
class Newsletter
{
public static function newsletter()
{
$tpl = new \Tpl;
return $tpl -> render( 'newsletter/newsletter' );
}
}

View File

@@ -0,0 +1,12 @@
<?php
namespace front\view;
class Scontainers
{
public static function scontainer( $id )
{
$tpl = new \Tpl;
$tpl -> scontainer = \front\factory\Scontainers::scontainer_details( $id );
return $tpl -> render( 'scontainers/scontainer' );
}
}

View File

@@ -0,0 +1,18 @@
<?php
namespace front\view;
class Search
{
public static function search_results( $articles )
{
$tpl = new \Tpl;
$tpl -> articles = $articles;
return $tpl -> render( 'search/search-results' );
}
public static function search_form()
{
$tpl = new \Tpl;
return $tpl -> render( 'search/search-form' );
}
}

View File

@@ -0,0 +1,396 @@
<?php
namespace front\view;
class Site
{
const menu_pattern = '/MENU:[0-9]*/';
const main_menu_pattern = '/MENU_GLOWNE:[0-9]*/';
const submenu_pattern = '/SUBMENU:[0-9]*/';
const container_pattern = '/KONTENER:[0-9]*/';
const language_pattern = '/LANG:[a-zA-Z0-9_-]*/';
const news_pattern = '/AKTUALNOSCI:([0-9]*)((:([0-9]*))?)/';
const news_list_pattern = '/AKTUALNOSCI_LISTA:([0-9]*)((:([0-9]*))?)/';
const top_news_pattern = '/NAJPOULARNIEJSZE_ARTYKULY:([0-9]*)((:([0-9]*))?)/';
const article_pattern = '/ARTYKUL:[0-9]*/';
const maps_pattern = '/\[MAPA](.*)\[\/MAPA]/';
public static function show()
{
global $page, $settings, $lang_id;
$settings['link_version'] ? $www = 'www.' : $www = '';
$settings['ssl'] == true ? $domain_prefix = 'https' : $domain_prefix = 'http';
$url = preg_replace( '#^(http(s)?://)?w{3}\.#', '$1', $_SERVER['SERVER_NAME'] );
if ( \S::get( 'article' ) )
$layout = \front\factory\Layouts::article_layout( \S::get( 'article' ) );
if ( !$layout )
$layout = \front\factory\Layouts::active_layout( $page['id'] );
if ( \S::get( 'layout_id' ) )
$layout = \front\factory\Layouts::layout_details( \S::get( 'layout_id' ) );
if ( $settings['devel'] == true and file_exists( 'devel.html' ) )
$html = file_get_contents( 'devel.html' );
else
{
if ( \S::is_mobile() and !empty( $layout['m_html'] ) )
$html = $layout['m_html'];
else
$html = $layout['html'];
}
\S::set_session( 'layout_id', $layout['layout_id'] ? $layout['layout_id'] : $layout['id'] );
if ( $settings['google_search_console'] )
$html = str_replace( '</head>', '<meta name="google-site-verification" content="' . $settings['google_search_console'] . '"></head>', $html );
if ( \S::get_session( 'contrast' ) )
$html = str_replace( '</head>', '<link rel="stylesheet" type="text/css" href="/layout/contrast.css"></head>', $html );
if ( $settings['facebook_link'] )
$html = str_replace( '</body>', \front\view\Site::facebook( $settings['facebook_link'] ) . '</body>', $html );
if ( strpos( $html, '[BANER_STRONA_GLOWNA]' ) === false )
$html = str_replace( '</body>', '[BANER_STRONA_GLOWNA]' . '</body>', $html );
if ( strpos( $html, '[WIDGET_TELEFON]' ) === false )
$html = str_replace( '</body>', '[WIDGET_TELEFON]' . '</body>', $html );
if ( $settings['ssl'] == true )
{
$layout['css'] = str_replace( 'http://', 'https://', $layout['css'] );
$layout['js'] = str_replace( 'http://', 'https://', $layout['js'] );
$layout['m_css'] = str_replace( 'http://', 'https://', $layout['m_css'] );
$layout['m_js'] = str_replace( 'http://', 'https://', $layout['m_js'] );
}
$html = str_replace( '[COPYRIGHT]', \front\view\Site::copyright(), $html );
$html = str_replace( '[BANER_STRONA_GLOWNA]', \front\view\Banners::main_banner( \front\factory\Banners::main_banner() ), $html );
$html = str_replace( '[BANERY]', \front\view\Banners::banners( \front\factory\Banners::banners() ), $html );
$html = str_replace( '[LICZNIK_ODWIEDZIN]', \front\view\Site::visit_counter( \S::get_session( 'visits' ) ), $html );
$html = str_replace( '[WYSZUKIWARKA]', \front\view\Search::search_form(), $html );
$html = str_replace( '[CHMURA_TAGOW]', \front\view\Articles::tags_cloud(), $html );
$html = str_replace( '[KONTRAST]', \front\view\Site::contrast(), $html );
$html = str_replace( '[NEWSLETTER]', \front\view\Newsletter::newsletter(), $html );
$html = str_replace( '[WIDGET_TELEFON]', $settings['widget_phone'] == 1 ? \front\view\Site::widget_phone() : '', $html );
if ( \S::is_mobile() and !empty( $layout['m_html'] ) )
$html = str_replace( '[CSS]', $layout['m_css'], $html );
else
$html = str_replace( '[CSS]', $layout['css'], $html );
if ( \S::is_mobile() and !empty( $layout['m_html'] ) )
$html = str_replace( '[JAVA_SCRIPT]', $layout['m_js'], $html );
else
$html = str_replace( '[JAVA_SCRIPT]', $layout['js'], $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] . ']', \front\view\Menu::menu(
\front\factory\Menu::menu_details( $menu_tmp[1] ), $page['id']
), $html );
}
preg_match_all( self::main_menu_pattern, $html, $menu );
if ( is_array( $menu[0] ) ) foreach( $menu[0] as $menu_tmp )
{
$menu_tmp = explode( ':', $menu_tmp );
$html = str_replace( '[MENU_GLOWNE:' . $menu_tmp[1] . ']', \front\view\Menu::main_menu(
\front\factory\Menu::menu_details( $menu_tmp[1] ), $page['id']
), $html );
}
preg_match_all( self::submenu_pattern, $html, $submenu );
if ( is_array( $submenu[0] ) ) foreach( $submenu[0] as $submenu_tmp )
{
$submenu_tmp = explode( ':', $submenu_tmp );
$html = str_replace( '[SUBMENU:' . $submenu_tmp[1] . ']', \front\view\Menu::submenu(
\front\factory\Menu::submenu_details( $submenu_tmp[1], $lang_id ), $page['id'], $submenu_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] . ']', \front\view\Scontainers::scontainer( $container_list_tmp[1] ), $html );
}
$html = str_replace( '[ZAWARTOSC]', \front\controls\Site::route(), $html );
preg_match_all( self::news_pattern, $html, $news_list );
if ( is_array( $news_list[0] ) ) foreach( $news_list[0] as $news_list_tmp )
{
$news_list_tmp = explode( ':', $news_list_tmp );
$news_list_tmp[2] != '' ? $news_limit = $news_list_tmp[2] : $news_limit = $settings['news_limit'];
$news_list_tmp[2] != '' ? $pattern = '[AKTUALNOSCI:' . $news_list_tmp[1] . ':' . $news_list_tmp[2] . ']' : $pattern = '[AKTUALNOSCI:' . $news_list_tmp[1] . ']';
$html = str_replace( $pattern, \front\view\Articles::news(
$news_list_tmp[1],
\front\factory\Articles::news( $news_list_tmp[1], $news_limit, $lang_id )
), $html );
}
// prosta lista aktualności z wybranej podstrony
preg_match_all( self::news_list_pattern, $html, $news_list );
if ( is_array( $news_list[0] ) ) foreach( $news_list[0] as $news_list_tmp )
{
$news_list_tmp = explode( ':', $news_list_tmp );
$news_list_tmp[2] != '' ? $news_limit = $news_list_tmp[2] : $news_limit = $settings['news_limit'];
$news_list_tmp[2] != '' ? $pattern = '[AKTUALNOSCI_LISTA:' . $news_list_tmp[1] . ':' . $news_list_tmp[2] . ']' : $pattern = '[AKTUALNOSCI_LISTA:' . $news_list_tmp[1] . ']';
$news_list = \Article::getNews( $news_list_tmp[1], $news_limit, $lang_id );
$view_news_list = \Article::newsList( $news_list );
$html = str_replace( $pattern, $view_news_list, $html );
}
// prosta lista z najpopularniejszymi artykułami
preg_match_all( self::top_news_pattern, $html, $news_list );
if ( is_array( $news_list[0] ) ) foreach( $news_list[0] as $news_list_tmp )
{
$news_list_tmp = explode( ':', $news_list_tmp );
$news_list_tmp[2] != '' ? $news_limit = $news_list_tmp[2] : $news_limit = $settings['news_limit'];
$news_list_tmp[2] != '' ? $pattern = '[NAJPOULARNIEJSZE_ARTYKULY:' . $news_list_tmp[1] . ':' . $news_list_tmp[2] . ']' : $pattern = '[NAJPOULARNIEJSZE_ARTYKULY:' . $news_list_tmp[1] . ']';
$news_list = \Article::getTopNews( $news_list_tmp[1], $news_limit, $lang_id );
$view_news_list = \Article::newsList( $news_list );
$html = str_replace( $pattern, $view_news_list, $html );
}
preg_match_all( self::language_pattern, $html, $language_list );
if ( is_array( $language_list[0] ) ) foreach( $language_list[0] as $language_list_tmp )
{
$language_list_tmp = explode( ':', $language_list_tmp );
$html = str_replace( '[LANG:' . $language_list_tmp[1] . ']', \S::lang( $language_list_tmp[1] ), $html );
}
if ( \S::get( 'article' ) )
{
$article = \front\factory\Articles::article_details( \S::get( 'article' ), $lang_id );
$title = $article['language']['meta_title'] ? $article['language']['meta_title'] : $article['language']['title'];
$meta_keywords = $article['language']['meta_keywords'];
$meta_description = $article['language']['meta_description'];
$og_image = $article['language']['main_image'] ? $article['language']['main_image'] : null;
}
else if ( \S::get( 'tag' ) )
{
$tag = \front\factory\Articles::tag_details( \S::get( 'tag' ) );
$title = 'Tag: ' . $tag['name'];
$meta_keywords = $tag['name'];
$meta_description = 'Artykuły oznaczone tagiem: ' . $tag['name'];
}
else if ( \S::get( 'search' ) )
{
$title = 'Wyniki wyszukiwania: ' . \S::get_session( 'search_txt' );
$meta_keywords = \S::get_session( 'search_txt' );
$meta_description = 'Wyniki wyszukiwania: ' . \S::get_session( 'search_txt' );
}
else
{
if ( $page['language']['meta_title'] )
$title = $page['language']['meta_title'];
else
$title = $page['language']['title'] . ' ● ' . $settings['firm_name'];
$meta_keywords = $page['language']['meta_keywords'];
$meta_description = $page['language']['meta_description'];
}
$seo_additional = \front\factory\SeoAdditional::seo_active();
if ( is_array( $seo_additional ) and count( $seo_additional ) ) foreach ( $seo_additional as $seo )
{
preg_match( '/' . str_replace( '/', '\/', $seo['url'] ) . '/', $_SERVER['REQUEST_URI'], $seo_results );
if ( is_array( $seo_results ) and count( $seo_results ) )
{
if ( $seo['title'] )
$title = $seo['title'];
if ( $seo['keywords'] )
$meta_keywords = $seo['keywords'];
if ( $meta_description )
$meta_description = $seo['description'];
if ( $seo['text'] )
$html = str_replace( '[DODATKOWA_TRESC]', '<div class="seo-additional-text">' . $seo['text'] . '</div>', $html );
else
$html = str_replace( '[DODATKOWA_TRESC]', '', $html );
}
}
$html = str_replace( '[DODATKOWA_TRESC]', '', $html );
$html = str_replace( '[TITLE]', $title, $html );
$html = str_replace( '[META_KEYWORDS]', $meta_keywords, $html );
$html = str_replace( '[META_DESCRIPTION]', $meta_description, $html );
$html = str_replace( '[OG_URL]', $domain_prefix . '://' . $www . $url . $_SERVER["REQUEST_URI"], $html );
$html = str_replace( '[OG_IMG]', $og_image ? ( $domain_prefix . '://' . $www . $url . '/' . $og_image ) : '', $html );
$html = str_replace( '[JEZYKI]', \front\view\Languages::languages(), $html );
$html = str_replace( '[KALENDARZ]', \front\view\Site::calendar(), $html );
$html = str_replace( '[TYTUL_STRONY]', \front\view\Site::title(
$page['language']['title'],
$page['show_title'],
$page['language']['site_title']
), $html );
$html = str_replace( '[STRONA_GLOWNA]', \front\factory\Pages::lang_url(
\front\factory\Pages::main_page_id(),
$lang_id,
\S::get_domain( $_SERVER['HTTP_HOST'] ),
\front\factory\Languages::default_domain()
), $html );
preg_match_all( self::article_pattern, $html, $articles_list );
if ( is_array( $articles_list[0] ) ) foreach( $articles_list[0] as $article_tmp )
{
$article_tmp = explode( ':', $article_tmp );
$html = str_replace( '[ARTYKUL:' . $article_tmp[1] . ']', \front\view\Articles::article_full( $article_tmp[1], $lang_id ), $html );
}
/* atrybut noindex */
if ( \S::get( 'article' ) )
{
\front\factory\Articles::article_noindex( \S::get( 'article' ) ) === '1' ? $noindex = 'noindex' : $noindex = 'index, follow';
$html = str_replace( '[META_INDEX]', '<meta name="robots" content="' . $noindex . '">', $html );
}
else
{
$page['language']['noindex'] === '1' ? $noindex = 'noindex' : $noindex = 'index, follow';
$html = str_replace( '[META_INDEX]', '<meta name="robots" content="' . $noindex . '">', $html );
}
if ( $page['language']['canonical'] )
$html = str_replace( '</head>', '<link rel="canonical" href="' . $page['language']['canonical'] . '" /></head>', $html );
while ( 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( str_replace( '&#39;', '"', $code ) );
$out .= ob_get_contents();
ob_end_clean();
$out .= $temp[1];
}
$html = $before . $out;
}
preg_match_all( self::maps_pattern, $html, $maps_list );
if ( is_array( $maps_list[1] ) and !empty( $maps_list[1] ) )
{
$html = strrev( implode( strrev( '<link class="footer" rel="stylesheet" type="text/css" href="/libraries/leaflet/leaflet.css"><script class="footer" type="text/javascript" src="/libraries/leaflet/leaflet.js"></script></head>' ), explode( strrev( '</head>' ), strrev( $html ), 2 ) ) );
foreach( $maps_list[1] as $map_tmp )
{
++$map_counter;
$map_settings = explode( '|', $map_tmp );
$html = str_replace( '[MAPA]' . $map_tmp . '[/MAPA]', \front\view\Articles::map( $map_settings, $map_counter ), $html );
}
}
$html = str_replace( '[ALERT]', \front\view\Site::alert(), $html );
return $html;
}
public static function widget_phone()
{
$tpl = new \Tpl;
return $tpl -> render( 'widgets/widget-phone' );
}
public static function facebook( $facebook_link )
{
$tpl = new \Tpl;
$tpl -> facebook_link = $facebook_link;
return $tpl -> render( 'site/facebook' );
}
public static function title( $title, $show_title, $site_title )
{
if ( !$show_title )
return false;
if ( $site_title )
$title = $site_title;
$tpl = new \Tpl;
$tpl -> title = $title;
return $tpl -> render( 'site/title' );
}
static public function alert()
{
if ( $alert = \S::get_session( 'alert' ) )
{
\S::delete_session( 'alert' );
\S::delete_session( 'alert-class' );
return \Tpl::view( 'site/alert', [
'alert' => $alert,
'alert_class' => \S::get_session( 'alert-class' )
] );
}
}
public static function copyright()
{
$tpl = new \Tpl;
return $tpl -> render( 'site/copyright' );
}
public static function contact()
{
$tpl = new \Tpl;
return $tpl -> render( 'site/contact' );
}
public static function cookie_information()
{
$tpl = new \Tpl;
return $tpl -> render( 'site/cookie-information' );
}
public static function calendar( $month = '', $year = '', $ajax = false )
{
global $settings, $lang_id;
if ( !$settings['calendar'] )
return false;
if ( !$month ) $month = date( 'n' );
if ( !$year ) $year = date( 'Y' );
$tpl = new \Tpl;
$tpl -> month = $month;
$tpl -> year = $year;
$tpl -> months = \S::months();
$tpl -> ajax = $ajax;
$tpl -> articles = \front\factory\Articles::articles_by_date( $month, $year, $lang_id );
return $tpl -> render( 'site/calendar' );
}
public static function visit_counter( $visit_counter )
{
$tpl = new \Tpl;
$tpl -> visit_counter = $visit_counter;
return $tpl -> render( 'site/visit-counter' );
}
public static function contrast()
{
$tpl = new \Tpl;
return $tpl -> render( 'site/contrast' );
}
}
?>

6
config.php Normal file
View File

@@ -0,0 +1,6 @@
<?php
$database['host'] = 'serwer1574995.home.pl';
$database['user'] = '18227288_0000017';
$database['password'] = 'NNNowa.Vidok';
$database['name'] = '18227288_0000017';
?>

2
contact.csv Normal file
View File

@@ -0,0 +1,2 @@
Name,Email,Phone,Message,Zip_code,Topic,Company,Invoice_number,Address,Timestamp
"Jacek Pyziak",biuro@project-pro.pl,,"Test z linkiem https://vidok.com/kontakt/ enterami i cytatami i cytatami",,"Zapytanie ze strony vidok.com",,,,"2024-04-03 11:01:37"
1 Name Email Phone Message Zip_code Topic Company Invoice_number Address Timestamp
2 Jacek Pyziak biuro@project-pro.pl Test z linkiem https://vidok.com/kontakt/ enterami i cytatami i cytatami Zapytanie ze strony vidok.com 2024-04-03 11:01:37

42
deklaracje.php Normal file
View File

@@ -0,0 +1,42 @@
<?
$uni = $_POST['uni'];
if ( $uni )
{
$uni = str_replace( [ ".", "/", " ", '"' ], [ "", "", "", "" ], $uni );
$my_files = array_diff( scandir( 'deklaracje/' ), array( '.', '..' ) );
if ( is_array( $my_files ) ) foreach ( $my_files as $file )
{
if ( strpos( $file, $uni ) )
{
$file_tmp = explode( '_', $file );
unset( $file_tmp[0] );
$file_tmp = implode( '_', $file_tmp );
$file_tmp = explode( '-', $file_tmp );
unset( $file_tmp[ count( $file_tmp ) - 1 ] );
$file_tmp = implode( '-', $file_tmp );
if ( $file_tmp == $uni )
{
// $out .= '<a href="/deklaracje/' . $file . '" target="_blank">' . $file . '</a><br/>';
$out .= '<div class="content__file">
<a href="/deklaracje/' . $file . '" target="_blank"> <i class="fa-solid fa-file"> </i>' . $file . '</a><br />
</div>';
}
}
}
if ( $out )
{
echo json_encode( [ 'result' => 'ok', 'out' => $out ] );
exit;
}
else
{
echo json_encode( [ 'result' => 'bad', 'msg' => '<p>Nie znaleziono żadnej deklaracji. Prawdopodobnie wpisany numer jest nieprawidłowy.</p>
' ] );
exit;
}
}
echo json_encode( [ 'result' => 'bad', 'msg' => '<p>Nie znaleziono żadnej deklaracji. Prawdopodobnie wpisany numer jest nieprawidłowy.</p>
' ] );
exit;

133
devel.html Normal file
View File

@@ -0,0 +1,133 @@
<!DOCTYPE html>
<html lang="pl">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>[TITLE]</title>
<meta property="og:title" content="[TITLE]" />
<meta property="og:type" content="website" />
<meta property="og:description" content="[META_DESCRIPTION]" />
<meta
property="og:image"
content="https://vidok.com/upload/filemanager/images/vidok-logo-black.png"
/>
<meta property="og:url" content="[OG_URL]" />
<meta name="keywords" content="[META_KEYWORDS]" />
<meta name="description" content="[META_DESCRIPTION]" />
<link rel="shortcut icon" type="image/x-icon" href="/images/favicon.png" />
[META_INDEX] [CSS] [JAVA_SCRIPT] [PHP]include
'templates_user/head-code.php';[/PHP]
</head>
<body>
[PHP]include 'templates_user/body-code.php';[/PHP]
<div class="button-contact">
<a href="/kontakt-nowy">
<img alt="" src="/upload/filemanager/icon/koperta.png" />
</a>
</div>
<div class="header-container fixed-top">
<div class="header">
<div class="container">
<div class="row">
<div class="col-5 col-sm-2">
<div class="logo-container">
<a href="/">
<div class="box-logo">
<div class="logo-front">
<img alt="" src="/upload/filemanager/images/vidok.png" />
</div>
<div class="logo-back">
<img
alt=""
src="/upload/filemanager/images/vidok-logo.png"
/>
</div>
</div>
</a>
</div>
</div>
<div class="col-7 col-sm-10">
[MENU_GLOWNE:1]
<a href="#" class="btn1 hidden-below-xs btn-popup-oferta">
Otrzymaj ofertę
</a>
<a href="#" class="btn1 hidden-above-xs btn-popup-oferta">
Oferta
</a>
<a class="search" href="#">
<img alt="" src="/upload/filemanager/icon/search-white.svg" />
</a>
[KONTENER:1] [JEZYKI]
<img alt="" src="/upload/filemanager/images/flaga-ue.png" />
</div>
</div>
</div>
</div>
<div class="search-box">
<div class="container">[WYSZUKIWARKA]</div>
</div>
</div>
<div class="subpage-content">
<div class="box-1">
<div class="container">[KONTENER:126]</div>
</div>
<div class="box-2">
<div class="container">[KONTENER:127]</div>
</div>
<div class="box-3">
<div class="container">
<div class="row">
<div class="col-12">
<iframe
width="100%"
height="500"
src="https://www.youtube.com/embed/GsXQgR2xjKg?si=vDZVFVGEUiOeV7hL"
title="YouTube video player"
frameborder="0"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
allowfullscreen
></iframe>
</div>
</div>
</div>
</div>
<div class="box-4">
<div class="container">[KONTENER:128]</div>
</div>
<div class="box-5">
<div class="container">[KONTENER:129]</div>
</div>
<div class="box-6">
<div class="container">[KONTENER:130]</div>
</div>
<div class="box-7">
<div class="container">[KONTENER:131]</div>
</div>
</div>
[PHP]include 'templates_user/modal/modal.php';[/PHP]
<div class="footer">
<div class="container">
<div class="row">
<div class="col-6 col-sm-4 col-md-3">[MENU:1]</div>
<div class="col-6 col-sm-4 col-md-3">[MENU:1]</div>
<div class="col-6 col-sm-4 col-md-3">
<p>Zobacz więcej</p>
[MENU:5]
</div>
<div class="col-6 col-sm-12 col-md-3">
<img alt="" src="/upload/filemanager/images/vidok-logo-black.png" />
</div>
</div>
</div>
</div>
</body>
</html>

52
download.php Normal file
View File

@@ -0,0 +1,52 @@
<?php
error_reporting( E_ALL & ~E_NOTICE & ~E_WARNING & ~E_DEPRECATED );
function __autoload_my_classes( $classname )
{
$q = explode( '\\' , $classname );
$c = array_pop( $q );
$f = 'autoload/' . implode( '/' , $q ) . '/class.' . $c . '.php';
if ( file_exists( $f ) )
require_once( $f );
}
spl_autoload_register( '__autoload_my_classes' );
date_default_timezone_set( 'Europe/Warsaw' );
require_once 'config.php';
require_once 'libraries/medoo/medoo.php';
session_start();
$mdb = new medoo( [
'database_type' => 'mysql',
'database_name' => $database['name'],
'server' => $database['host'],
'username' => $database['user'],
'password' => $database['password'],
'charset' => 'utf8'
] );
if ( $file_id = \S::get( 'file' ) )
{
$result = $mdb -> get( 'pp_articles_files', [ 'src' ], [ 'id' => $file_id ] );
if ( $result )
{
$file = ltrim( $result['src'], '/' );
if ( file_exists( $file ) )
{
header( 'Content-Description: File Transfer' );
header( 'Content-Type: application/octet-stream' );
header( 'Content-Disposition: attachment; filename=' . basename( $file ) );
header( 'Expires: 0');
header( 'Cache-Control: must-revalidate');
header( 'Pragma: public');
header( 'Content-Length: ' . filesize( $file ) );
readfile( $file );
exit;
}
}
}
header( 'Content-Type: text/html; charset=utf-8' );
exit( 'Nieprawidłowy plik.' );
?>

9
get_file.php Normal file
View File

@@ -0,0 +1,9 @@
<?php
$currentURL = $_GET['currentPage'];
$fileName = $_GET['fileName'];
$fileUrl = $_GET['fileUrl'];
header('Content-type: application/pdf');
header('Content-Disposition: attachment; filename="' . $fileName . '"');
readfile($fileUrl);
?>

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Some files were not shown because too many files have changed in this diff Show More