+
+ =
+ \Html::input(
+ array(
+ 'label' => 'Nazwa firmy',
+ 'name' => 'firm_name',
+ 'id' => 'firm_name',
+ 'value' => $this -> settings['firm_name']
+ )
+ );
+ ?>
+ =
+ \Html::textarea(
+ array(
+ 'label' => 'Dodatkowe informacje',
+ 'name' => 'additional_info',
+ 'id' => 'additional_info',
+ 'value' => $this -> settings['additional_info']
+ )
+ );
+ ?>
+ =
+ \Html::input_switch(
+ array(
+ 'label' => 'Mapa',
+ 'name' => 'google_maps',
+ 'checked' => $this -> settings['google_maps'] == 1 ? true : false
+ )
+ );
+ ?>
+ =
+ \Html::textarea(
+ array(
+ 'label' => 'Mapa - adres',
+ 'name' => 'firm_adress',
+ 'id' => 'firm_adress',
+ 'value' => $this -> settings['firm_adress']
+ )
+ );
+ ?>
+ =
+ \Html::input_switch(
+ array(
+ 'label' => 'Widget "Telefon"',
+ 'name' => 'widget_phone',
+ 'checked' => $this -> settings['widget_phone'] == 1 ? true : false
+ )
+ );
+ ?>
+
+
+ =
+ \Html::input_switch(
+ array(
+ 'label' => 'Formularz kontaktowy',
+ 'name' => 'contact_form',
+ 'checked' => $this -> settings['contact_form'] == 1 ? true : false
+ )
+ );
+ ?>
+ =
+ \Html::input(
+ array(
+ 'label' => 'Email kontaktowy',
+ 'name' => 'contact_email',
+ 'id' => 'contact_email',
+ 'value' => $this -> settings['contact_email']
+ )
+ );
+ ?>
+ =
+ \Html::input(
+ array(
+ 'label' => 'Email - host',
+ 'name' => 'email_host',
+ 'id' => 'email_host',
+ 'value' => $this -> settings['email_host']
+ )
+ );
+ ?>
+ =
+ \Html::input(
+ array(
+ 'label' => 'Email - port',
+ 'name' => 'email_port',
+ 'id' => 'email_port',
+ 'value' => $this -> settings['email_port']
+ )
+ );
+ ?>
+ =
+ \Html::input(
+ array(
+ 'label' => 'Email - login',
+ 'name' => 'email_login',
+ 'id' => 'email_login',
+ 'value' => $this -> settings['email_login']
+ )
+ );
+ ?>
+ =
+ \Html::input(
+ array(
+ 'label' => 'Email - hasło',
+ 'name' => 'email_password',
+ 'id' => 'email_password',
+ 'value' => $this -> settings['email_password'],
+ 'type' => 'text'
+ )
+ );
+ ?>
+ = \Html::input_switch( [
+ 'label' => 'Captcha w formularzu kontaktowym',
+ 'name' => 'contact_form_captcha',
+ 'checked' => $this -> settings['contact_form_captcha'] == 1 ? true : false
+ ] );
+ ?>
+
+
+
+
+
+
+ = \Html::input( [
+ 'label' => 'Maksmalna wielkość zdjęcia (px)',
+ 'name' => 'image_px',
+ 'id' => 'image_px',
+ 'value' => $this -> settings['image_px']
+ ] );
+ ?>
+
+
+ =
+ \Html::input(
+ array(
+ 'label' => 'Klucz Google Search Console',
+ 'name' => 'google_search_console',
+ 'id' => 'google_search_console',
+ 'value' => $this -> settings['google_search_console']
+ )
+ );
+ ?>
+ =
+ \Html::input(
+ array(
+ 'label' => 'Facebook link',
+ 'name' => 'facebook_link',
+ 'id' => 'facebook_link',
+ 'value' => $this -> settings['facebook_link']
+ )
+ );
+ ?>
+ =
+ \Html::textarea(
+ array(
+ 'label' => 'Kod statystyk',
+ 'name' => 'statistic_code',
+ 'id' => 'statistic_code',
+ 'value' => $this -> settings['statistic_code'],
+ 'rows' => 10
+ )
+ );
+ ?>
+ =
+ \Html::textarea(
+ array(
+ 'label' => 'Własne reguły htacess',
+ 'name' => 'htaccess',
+ 'id' => 'htaccess',
+ 'value' => $this -> settings['htaccess'],
+ 'rows' => 10
+ )
+ );
+ ?>
+ =
+ \Html::textarea(
+ array(
+ 'label' => 'Własne reguły robots.txt',
+ 'name' => 'robots',
+ 'id' => 'robots',
+ 'value' => $this -> settings['robots'],
+ 'rows' => 10
+ )
+ );
+ ?>
+
+
+
+
+
+
+
+
+
+ = \Html::select( [
+ 'label' => "Struktura linków",
+ 'name' => "links_structure",
+ 'values' => [ 0 => 'skrócona', 1 => 'rozwinięta' ],
+ 'value' => $this -> settings['links_structure'] ? 1 : 0
+ ] );?>
+
+
+ = \Html::select( [
+ 'label' => "Wersja strony",
+ 'name' => "link_version",
+ 'values' => [ 0 => 'bez www', 1 => 'z www' ],
+ 'value' => $this -> settings['link_version'] ? 1 : 0
+ ] );?>
+
+
+ = \Html::select( [
+ 'label' => "Wersja adresów url",
+ 'name' => "url_version",
+ 'values' => [ 0 => 'bez / na końcu adresu url', 1 => 'z / na końcu adresu url' ],
+ 'value' => $this -> settings['url_version'] ? 1 : 0
+ ] );?>
+
+
+ = \Html::select( [
+ 'label' => "Newsletter",
+ 'name' => "newsletter_cron",
+ 'values' => [ 0 => 'wysyłka za pomocą cron i strony', 1 => 'wysyłka za pomocą cron' ],
+ 'value' => $this -> settings['newsletter_cron'] ? 1 : 0
+ ] );?>
+
+
+
+
+ = Html::input(
+ array(
+ 'label' => 'Numer licencji',
+ 'name' => 'update_key',
+ 'id' => 'update_key',
+ 'value' => $this -> settings['update_key']
+ )
+ );
+ ?>
+
+
+
+ $out = ob_get_clean();
+
+ $grid = new \gridEdit;
+ $grid -> id = 'settings-edit';
+ $grid -> gdb_opt = $gdb;
+ $grid -> include_plugins = true;
+ $grid -> title = 'Edycja ustawień';
+ $grid -> actions = [
+ 'save' => [
+ 'url' => '/admin/settings/settings_save/',
+ 'back_url' => '/admin/settings/view/'
+ ]
+ ];
+ $grid -> external_code = $out;
+ echo $grid -> draw();
+ ?>
+
+
+
+
\ No newline at end of file
diff --git a/admin/templates/site/main-layout.php b/admin/templates/site/main-layout.php
new file mode 100644
index 0000000..4630e65
--- /dev/null
+++ b/admin/templates/site/main-layout.php
@@ -0,0 +1,331 @@
+ global $user, $config, $settings;?>
+
+
+
+
cmsPro
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ if ( $alert = \S::get_session( 'alert' ) ):
+ \S::alert( false );
+ ?>
+
+
+
+ ×
+
+ = $alert;?>
+
+
+
+ endif;
+ ?>
+ = $this -> content;?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/admin/templates/site/unlogged-layout.php b/admin/templates/site/unlogged-layout.php
new file mode 100644
index 0000000..f79ab1b
--- /dev/null
+++ b/admin/templates/site/unlogged-layout.php
@@ -0,0 +1,93 @@
+ global $user, $config, $settings;?>
+
+
+
+
cmsPro
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/admin/templates/site/unlogged.php b/admin/templates/site/unlogged.php
new file mode 100644
index 0000000..000ebd4
--- /dev/null
+++ b/admin/templates/site/unlogged.php
@@ -0,0 +1,27 @@
+ global $user, $config, $settings;?>
+
+
+
+
cmsPro
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ = $this -> content;?>
+
+
+
+
+
\ No newline at end of file
diff --git a/admin/templates/update/main-view.php b/admin/templates/update/main-view.php
new file mode 100644
index 0000000..577fb15
--- /dev/null
+++ b/admin/templates/update/main-view.php
@@ -0,0 +1,165 @@
+ global $db; ob_start();?>
+= \Html::form_text( [
+ 'label' => 'Twoja wersja systemu',
+ 'id' => 'ver',
+ 'text' => $this -> ver
+ ] );?>
+= \Html::form_text( [
+ 'label' => 'Aktualna wersja systemu',
+ 'text' => $this -> new_ver,
+ 'id' => 'new_ver'
+ ] );?>
+
+ $ver_new = $this -> new_ver;
+ $ver = $this -> ver;
+ $valuemax = ( $ver_new - $ver ) * 1000;
+?>
+
+
+ if ( $this -> ver < $this -> new_ver ):?>
+
+ endif;?>
+ if ( $this -> ver < $this -> new_ver ):?>
+
+ endif;?>
+
+ if ( $this -> ver < $this -> new_ver ):?>
+
* Przed aktualizacją systemu zalecane jest wykonanie pełnej kopii zapasowej.
+
+ endif;?>
+
+$out = ob_get_clean();
+
+$grid = new \gridEdit;
+$grid -> id = 'update-view';
+$grid -> gdb_opt = $gdb;
+$grid -> include_plugins = true;
+$grid -> title = 'Aktualizacja systemu';
+$grid -> default_buttons = false;
+$grid -> external_code = $out;
+echo $grid -> draw();
+?>
+
+ob_start();
+echo $versions = file_get_contents( 'http://www.cmspro.project-dc.pl/updates/changelog.php' );
+$out = ob_get_clean();
+
+$grid = new \gridEdit;
+$grid -> id = 'changelog';
+$grid -> gdb_opt = $gdb;
+$grid -> include_plugins = true;
+$grid -> title = 'Changelog';
+$grid -> default_buttons = false;
+$grid -> external_code = $out;
+echo $grid -> draw();
+?>
+
\ No newline at end of file
diff --git a/admin/templates/users/user-2fa.php b/admin/templates/users/user-2fa.php
new file mode 100644
index 0000000..fb7f741
--- /dev/null
+++ b/admin/templates/users/user-2fa.php
@@ -0,0 +1,49 @@
+
\ No newline at end of file
diff --git a/admin/templates/users/user-edit.php b/admin/templates/users/user-edit.php
new file mode 100644
index 0000000..6120bc2
--- /dev/null
+++ b/admin/templates/users/user-edit.php
@@ -0,0 +1,344 @@
+privileges;
+?>
+
+
+$this->user['id'] ? $password_param = 'optional' : $password_param = 'require';
+$out = ob_get_clean();
+
+$grid = new \gridEdit;
+$grid->gdb_opt = $gdb;
+$grid->include_plugins = true;
+$grid->title = 'Zapisz użytkownika';
+$grid->fields = [
+ [
+ 'db' => 'id',
+ 'type' => 'hidden',
+ 'value' => $this->user['id']
+ ], [
+ 'db' => 'admin',
+ 'type' => 'hidden',
+ 'value' => '1'
+ ], [
+ 'name' => 'Login',
+ 'db' => 'login',
+ 'type' => 'text',
+ 'value' => $this->user['login'],
+ 'params' => ['class' => 'require', 'function' => 'check_login']
+ ], [
+ 'name' => 'Aktywny',
+ 'db' => 'status',
+ 'type' => 'input_switch',
+ 'checked' => $this->user['status'] ? true : false
+ ], [
+ 'db' => 'twofa_enabled',
+ 'name' => 'Dwustopniowe uwierzytelnianie (2FA)',
+ 'type' => 'input_switch',
+ 'checked' => $this -> user['twofa_enabled'] ? true : false,
+ ], [
+ 'db' => 'twofa_email',
+ 'name' => 'E-mail do 2FA',
+ 'type' => 'text',
+ 'value' => $this -> user['twofa_email'],
+ ], [
+ 'name' => 'Aktywny do',
+ 'db' => 'active_to',
+ 'type' => 'text',
+ 'id' => 'active_to',
+ 'value' => $this->user['active_to'] == '0000-00-00' ? '' : $this->user['active_to']
+ ],
+ [
+ 'name' => 'Hasło',
+ 'db' => 'password',
+ 'type' => 'password',
+ 'params' => ['class' => $password_param, 'min' => 5]
+ ],
+ [
+ 'name' => 'Hasło - powtórz',
+ 'db' => 'password_re',
+ 'type' => 'password',
+ 'params' => ['class' => $password_param, 'min' => 5, 'equal' => 'password', 'error_txt' => 'Podane hasła są różne']
+ ]
+];
+$grid->actions = [
+ 'save' => ['url' => '/admin/users/user_save/', 'back_url' => '/admin/users/view_list/'],
+ 'cancel' => ['url' => '/admin/users/view_list/']
+];
+$grid->external_code = $out;
+$grid->persist_edit = true;
+echo $grid->draw();
+?>
+
+
\ No newline at end of file
diff --git a/admin/templates/users/users-list.php b/admin/templates/users/users-list.php
new file mode 100644
index 0000000..f1623fd
--- /dev/null
+++ b/admin/templates/users/users-list.php
@@ -0,0 +1,47 @@
+ gdb_opt = $gdb;
+$grid -> order = [ 'column' => 'login', 'type' => 'ASC' ];
+$grid -> where = [ 'id[!]' => 1 ];
+$grid -> search = [
+ [ 'name' => 'Login', 'db' => 'login', 'type' => 'text' ],
+ [ 'name' => 'Aktywny', 'db' => 'status', 'type' => 'select', 'replace' => [ 'array' => [ 0 => 'nie', 1 => 'tak' ] ] ]
+ ];
+$grid -> columns_view = [
+ [
+ 'name' => 'Lp.',
+ 'th' => [ 'class' => 'g-lp' ],
+ 'td' => [ 'class' => 'g-center' ],
+ 'autoincrement' => true
+ ],
+ [
+ 'name' => 'Aktywny',
+ 'db' => 'status',
+ 'replace' => [ 'array' => [ 0 => '
nie ', 1 => 'tak' ] ],
+ 'th' => [ 'class' => 'g-center', 'style' => 'width: 150px;' ],
+ 'td' => [ 'class' => 'g-center' ]
+ ],
+ [
+ 'name' => 'Login',
+ 'db' => 'login',
+ 'sort' => true
+ ],
+ [
+ 'name' => 'Edytuj',
+ 'action' => [ 'type' => 'edit', 'url' => '/admin/users/user_edit/id=[id]' ],
+ 'th' => [ 'class' => 'g-center', 'style' => 'width: 50px;' ],
+ 'td' => [ 'class' => 'g-center' ]
+ ],
+ [
+ 'name' => 'Usuń',
+ 'action' => [ 'type' => 'delete', 'url' => '/admin/users/user_delete/id=[id]' ],
+ 'th' => [ 'class' => 'g-center', 'style' => 'width: 50px;' ],
+ 'td' => [ 'class' => 'g-center' ]
+ ]
+ ];
+$grid -> buttons = [
+ [ 'label' => 'Dodaj użytkownika', 'url' => '/admin/users/user_edit/', 'icon' => 'fa-plus-circle', 'class' => 'btn-success' ]
+ ];
+echo $grid -> draw();
\ No newline at end of file
diff --git a/autoload/.1645576321.suspected b/autoload/.1645576321.suspected
deleted file mode 100644
index e69de29..0000000
diff --git a/autoload/.1645635829.suspected b/autoload/.1645635829.suspected
deleted file mode 100644
index e69de29..0000000
diff --git a/autoload/.1645635840.suspected b/autoload/.1645635840.suspected
deleted file mode 100644
index e69de29..0000000
diff --git a/autoload/.1645641524.suspected b/autoload/.1645641524.suspected
deleted file mode 100644
index e69de29..0000000
diff --git a/autoload/.1645661211.suspected b/autoload/.1645661211.suspected
deleted file mode 100644
index e69de29..0000000
diff --git a/autoload/.1645686576.suspected b/autoload/.1645686576.suspected
deleted file mode 100644
index e69de29..0000000
diff --git a/autoload/.1645704702.suspected b/autoload/.1645704702.suspected
deleted file mode 100644
index e69de29..0000000
diff --git a/autoload/.1645708327.suspected b/autoload/.1645708327.suspected
deleted file mode 100644
index e69de29..0000000
diff --git a/autoload/.1645796929.suspected b/autoload/.1645796929.suspected
deleted file mode 100644
index e69de29..0000000
diff --git a/autoload/.1645796935.suspected b/autoload/.1645796935.suspected
deleted file mode 100644
index e69de29..0000000
diff --git a/autoload/.1645796948.suspected b/autoload/.1645796948.suspected
deleted file mode 100644
index e69de29..0000000
diff --git a/autoload/admin/.1645555001.suspected b/autoload/admin/.1645555001.suspected
deleted file mode 100644
index e69de29..0000000
diff --git a/autoload/admin/.1645576320.suspected b/autoload/admin/.1645576320.suspected
deleted file mode 100644
index e69de29..0000000
diff --git a/autoload/admin/.1645641515.suspected b/autoload/admin/.1645641515.suspected
deleted file mode 100644
index e69de29..0000000
diff --git a/autoload/admin/.1645641527.suspected b/autoload/admin/.1645641527.suspected
deleted file mode 100644
index e69de29..0000000
diff --git a/autoload/admin/class.Site.php b/autoload/admin/class.Site.php
index db3c613..e44462c 100644
--- a/autoload/admin/class.Site.php
+++ b/autoload/admin/class.Site.php
@@ -1,71 +1,216 @@
$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':
+ $login = \S::get('login');
+ $pass = \S::get('password');
- setcookie( $cookie_name, "", time() -(86400), "/", $domain );
- session_destroy();
- header( 'Location: /admin/' );
- exit;
- break;
+ $result = \admin\factory\Users::logon($login, $pass);
+
+ if ($result == 1)
+ {
+ $user = \admin\factory\Users::details($login);
+
+ if ($user['twofa_enabled'] == 1)
+ {
+ \S::set_session('twofa_pending', [
+ 'uid' => (int)$user['id'],
+ 'login' => $login,
+ 'remember' => (bool)\S::get('remember'),
+ 'started' => time(),
+ ]);
+
+ if (!\admin\factory\Users::send_twofa_code((int)$user['id']))
+ {
+ \S::alert('Nie udało się wysłać kodu 2FA. Spróbuj ponownie.');
+ \S::delete_session('twofa_pending');
+ header('Location: /admin/');
+ exit;
+ }
+
+ header('Location: /admin/user/twofa/');
+ exit;
+ }
+ else
+ {
+ $user = \admin\factory\Users::details($login);
+
+ self::finalize_admin_login(
+ $user,
+ $domain,
+ $cookie_name,
+ (bool)\S::get('remember')
+ );
+
+ header('Location: /admin/articles/view_list/');
+ exit;
+ }
+ }
+ else
+ {
+ if ($result == -1)
+ {
+ \S::alert('Z powodu 5 nieudanych prób Twoje konto zostało zablokowane.');
+ }
+ else
+ {
+ \S::alert('Podane hasło jest nieprawidłowe lub użytkownik nie istnieje.');
+ }
+ header('Location: /admin/');
+ exit;
+ }
+ }
+ break;
+
+ case 'user-2fa-verify':
+ {
+ $pending = \S::get_session('twofa_pending');
+ if (!$pending || empty($pending['uid']))
+ {
+ \S::alert('Sesja 2FA wygasła. Zaloguj się ponownie.');
+ header('Location: /admin/');
+ exit;
+ }
+
+ $code = trim((string)\S::get('twofa'));
+ if (!preg_match('/^\d{6}$/', $code))
+ {
+ \S::alert('Nieprawidłowy format kodu.');
+ header('Location: /admin/user/twofa/');
+ exit;
+ }
+
+ $ok = \admin\factory\Users::verify_twofa_code((int)$pending['uid'], $code);
+ if (!$ok)
+ {
+ \S::alert('Błędny lub wygasły kod.');
+ header('Location: /admin/user/twofa/');
+ exit;
+ }
+
+ // 2FA OK — finalna sesja
+ $user = \admin\factory\Users::details($pending['login']);
+ \S::set_session('user', $user);
+ \S::delete_session('twofa_pending');
+
+ // Remember me – BEZPIECZNY podpis HMAC:
+ if (!empty($pending['remember']))
+ {
+ $payloadArr = ['login' => $user['login'], 'ts' => time()];
+ $json = json_encode($payloadArr, JSON_UNESCAPED_SLASHES);
+ $sig = hash_hmac('sha256', $json, APP_SECRET_KEY);
+ $payload = base64_encode($json . '.' . $sig);
+
+ setcookie($cookie_name, $payload, [
+ 'expires' => time() + (86400 * 14),
+ 'path' => '/',
+ 'domain' => $domain,
+ 'secure' => true,
+ 'httponly' => true,
+ 'samesite' => 'Lax',
+ ]);
+ }
+
+ header('Location: /admin/articles/view_list/');
+ exit;
+ }
+ break;
+
+ case 'user-2fa-resend':
+ {
+ $pending = \S::get_session('twofa_pending');
+ if (!$pending || empty($pending['uid']))
+ {
+ \S::alert('Sesja 2FA wygasła. Zaloguj się ponownie.');
+ header('Location: /admin/');
+ exit;
+ }
+
+ if (!\admin\factory\Users::send_twofa_code((int)$pending['uid'], true))
+ {
+ \S::alert('Kod można wysłać ponownie po krótkiej przerwie.');
+ }
+ else
+ {
+ \S::alert('Nowy kod został wysłany.');
+ }
+ header('Location: /admin/user/twofa/');
+ exit;
+ }
+ break;
+
+ case 'user-logout':
+ {
+ setcookie($cookie_name, "", time() - 86400, "/", $domain);
+ \S::delete_session('twofa_pending');
+ 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() );
+
+ $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.' );
+ \S::alert('Nieprawidłowy adres url.');
return false;
}
}
+
+ static public function finalize_admin_login(array $user, string $domain, string $cookie_name, bool $remember = false) {
+ \S::set_session('user', $user);
+ \S::delete_session('twofa_pending');
+
+ if ($remember)
+ {
+ $payloadArr = [
+ 'login' => $user['login'],
+ 'ts' => time()
+ ];
+
+ $json = json_encode($payloadArr, JSON_UNESCAPED_SLASHES);
+ $sig = hash_hmac('sha256', $json, self::APP_SECRET_KEY);
+ $payload = base64_encode($json . '.' . $sig);
+
+ setcookie($cookie_name, $payload, [
+ 'expires' => time() + (86400 * 14),
+ 'path' => '/',
+ 'domain' => $domain,
+ 'secure' => true,
+ 'httponly' => true,
+ 'samesite' => 'Lax',
+ ]);
+ }
+ }
}
diff --git a/autoload/admin/controls/class.Articles.php b/autoload/admin/controls/class.Articles.php
index 3c29724..860eb24 100644
--- a/autoload/admin/controls/class.Articles.php
+++ b/autoload/admin/controls/class.Articles.php
@@ -27,6 +27,22 @@ class Articles
exit;
}
+ static public function files_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::files_order_save( \S::get( 'article_id' ), \S::get( 'order' ) ) )
+ echo json_encode( [ 'status' => 'ok', 'msg' => 'Artykuł został zapisany.' ] );
+
+ exit;
+ }
+
public static function gallery_order_save()
{
global $user;
@@ -98,8 +114,8 @@ class Articles
$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['id'], $values['title'], $values['main_image'], $values['entry'], $values['text'], $values['table_of_contents'], $values['status'], $values['show_title'], $values['show_table_of_contents'], $values['show_date_add'], $values['date_add'],
+ $values['show_date_modify'], $values['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
) )
@@ -115,23 +131,23 @@ class Articles
{
global $user;
- if ( !\admin\factory\Users::check_privileges( 'article_administration',
- $user['id'] ) )
+ 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()
- ] );
+ '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(),
+ 'user' => $user
+ ] );
}
public static function view_list()
diff --git a/autoload/admin/controls/class.Settings.php b/autoload/admin/controls/class.Settings.php
index d328bd1..ba01075 100644
--- a/autoload/admin/controls/class.Settings.php
+++ b/autoload/admin/controls/class.Settings.php
@@ -54,6 +54,7 @@ class Settings
\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::alert( 'Ustawienia zostały zapisane.' );
diff --git a/autoload/admin/controls/class.Users.php b/autoload/admin/controls/class.Users.php
index 42c377a..a8e8a1c 100644
--- a/autoload/admin/controls/class.Users.php
+++ b/autoload/admin/controls/class.Users.php
@@ -1,59 +1,65 @@
\Tpl::view( 'users/user-2fa' )
+ ] );
+ }
}
?>
diff --git a/autoload/admin/factory/class.Articles.php b/autoload/admin/factory/class.Articles.php
index 55189a2..da033a1 100644
--- a/autoload/admin/factory/class.Articles.php
+++ b/autoload/admin/factory/class.Articles.php
@@ -86,6 +86,24 @@ class Articles
return true;
}
+ static public function files_order_save( $article_id, $order )
+ {
+ global $mdb;
+
+ $order = explode( ';', $order );
+ if ( is_array( $order ) and !empty( $order ) ) foreach ( $order as $file_id )
+ {
+ $mdb -> update( 'pp_articles_files', [
+ 'o' => (int)$i++
+ ], [
+ 'AND' => [
+ 'article_id' => $article_id,
+ 'id' => $file_id
+ ]
+ ] );
+ }
+ }
+
public static function gallery_order_save( $article_id, $order )
{
global $mdb;
@@ -222,7 +240,7 @@ class Articles
$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['files'] = $mdb -> select( 'pp_articles_files', '*', [ 'article_id' => (int)$article_id, 'ORDER' => [ 'o' => 'ASC', 'id' => 'ASC' ] ] );
$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 ] );
@@ -238,7 +256,7 @@ class Articles
}
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,
+ $article_id, $title, $main_image, $entry, $text, $table_of_contents, $status, $show_title, $show_table_of_contents, $show_date_add, $date_add, $show_date_modify, $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 )
{
@@ -251,10 +269,11 @@ class Articles
{
$mdb -> insert( 'pp_articles', [
'show_title' => $show_title == 'on' ? 1 : 0,
+ 'show_table_of_contents' => $show_table_of_contents == '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' ),
+ 'date_add' => date( 'Y-m-d H:i:s' ),
+ '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,
@@ -435,9 +454,11 @@ class Articles
{
$mdb -> update( 'pp_articles', [
'show_title' => $show_title == 'on' ? 1 : 0,
+ 'show_table_of_contents' => $show_table_of_contents == 'on' ? 1 : 0,
'show_date_add' => $show_date_add == 'on' ? 1 : 0,
+ 'date_add' => $date_add,
'show_date_modify' => $show_date_modify == 'on' ? 1 : 0,
- 'date_modify' => date( 'Y-m-d H:i:s' ),
+ 'date_modify' => $date_modify ? $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,
diff --git a/autoload/admin/factory/class.Users.php b/autoload/admin/factory/class.Users.php
index a7c68eb..8e5f105 100644
--- a/autoload/admin/factory/class.Users.php
+++ b/autoload/admin/factory/class.Users.php
@@ -1,185 +1,306 @@
delete( 'pp_users', [ 'id' => (int)$user_id ] );
-
+ return $mdb->delete('pp_users', ['id' => (int)$user_id]);
}
-
- public static function user_details( $user_id )
+
+ public static function user_details($user_id)
{
global $mdb;
- return $mdb -> get( 'pp_users', '*', [ 'id' => (int)$user_id ] );
+ return $mdb->get('pp_users', '*', ['id' => (int)$user_id]);
}
-
- public static function user_privileges( $user_id )
+
+ public static function user_privileges($user_id)
{
global $mdb;
- return $mdb -> select( 'pp_users_privileges', '*', ['id_user' => (int)$user_id]);
+ 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 )
+
+ public static function user_save($user_id, $login, $status, $active_to, $password, $password_re, $admin, $privileges, $twofa_enabled = 0, $twofa_email = '' )
{
global $mdb, $lang;
- $mdb -> delete( 'pp_users_privileges', [ 'id_user' => (int) $user_id ] );
+ $mdb->delete('pp_users_privileges', ['id_user' => (int) $user_id]);
- if ( !$user_id )
+ if (!$user_id)
{
- if ( strlen( $password ) < 5 )
- return $response = [ 'status' => 'error', 'msg' => 'Podane hasło jest zbyt krótkie.' ];
+ 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 ($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 ($mdb->insert(
+ 'pp_users',
+ [
+ 'login' => $login,
+ 'status' => $status == 'on' ? 1 : 0,
+ 'active_to' => $active_to == '' ? NULL : $active_to,
+ 'admin' => $admin,
+ 'password' => md5($password),
+ 'twofa_enabled' => $twofa_enabled == 'on' ? 1 : 0,
+ 'twofa_email' => $twofa_email
+ ]
+ ))
+ $id_user = $mdb->get('pp_users', 'id', ['ORDER' => ['id' => 'DESC']]);
- if ( is_array( $privileges ) )
+ if (is_array($privileges))
{
- foreach ( $privileges as $pri )
+ foreach ($privileges as $pri)
{
- $mdb -> insert( 'pp_users_privileges',
- [
- 'name' => $pri,
- 'id_user' => $id_user
- ] );
+ $mdb->insert(
+ 'pp_users_privileges',
+ [
+ 'name' => $pri,
+ 'id_user' => $id_user
+ ]
+ );
}
}
else
{
- $mdb -> insert( 'pp_users_privileges',
- [
- 'name' => $privileges,
- 'id_user' => $id_user
- ] );
+ $mdb->insert(
+ 'pp_users_privileges',
+ [
+ 'name' => $privileges,
+ 'id_user' => $id_user
+ ]
+ );
}
- return $response = [ 'status' => 'ok', 'msg' => 'Użytkownik został zapisany.' ];
+ 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 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 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
- ] );
+ 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
- ] );
+ $mdb->update('pp_users', [
+ 'login' => $login,
+ 'admin' => $admin,
+ 'status' => $status == 'on' ? 1 : 0,
+ 'active_to' => $active_to == '' ? NULL : $active_to,
+ 'error_logged_count' => 0,
+ 'twofa_enabled' => $twofa_enabled == 'on' ? 1 : 0,
+ 'twofa_email' => $twofa_email
+ ], [
+ 'id' => (int) $user_id
+ ]);
- if ( is_array( $privileges ) )
+ if (is_array($privileges))
{
- foreach ( $privileges as $pri )
+ foreach ($privileges as $pri)
{
- $mdb -> insert( 'pp_users_privileges', [
- 'name' => $pri,
- 'id_user' => $user_id
- ] );
+ $mdb->insert('pp_users_privileges', [
+ 'name' => $pri,
+ 'id_user' => $user_id
+ ]);
}
}
else
{
- $mdb -> insert( 'pp_users_privileges', [
- 'name' => $privileges,
- 'id_user' => $user_id
- ] );
+ $mdb->insert('pp_users_privileges', [
+ 'name' => $privileges,
+ 'id_user' => $user_id
+ ]);
}
- return $response = [ 'status' => 'ok', 'msg' => 'Uzytkownik został zapisany.' ];
+ return $response = ['status' => 'ok', 'msg' => 'Uzytkownik został zapisany.'];
}
\S::delete_cache();
}
- public static function check_login( $login, $user_id )
+ 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' ];
+
+ 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 )
+
+ public static function logon($login, $password)
{
global $mdb;
-
- if ( !$mdb -> get( 'pp_users', '*', [ 'login' => $login ] ) )
+
+ 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 ]
- ]
- ] ) )
+
+ 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 ] );
+ $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', ['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 ] );
+ $mdb->update('pp_users', ['status' => 0], ['login' => $login]);
return -1;
}
}
return 0;
}
-
- public static function details( $login )
+
+ public static function details($login)
{
global $mdb;
- return $mdb -> get( 'pp_users', '*', [ 'login' => $login ] );
+ return $mdb->get('pp_users', '*', ['login' => $login]);
}
-
- public static function check_privileges( $name, $user_id )
+
+ public static function check_privileges($name, $user_id)
{
global $mdb;
-
- if ( $user_id == 1 )
+
+ 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;
- }
+ 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;
+ }
+ }
+
+ static public function get_by_id(int $userId): ?array
+ {
+
+ global $mdb;
+ return $mdb->get('pp_users', '*', ['id' => $userId]) ?: null;
+ }
+
+ static public function send_twofa_code(int $userId, bool $resend = false): bool
+ {
+
+ $user = self::get_by_id($userId);
+ if (!$user)
+ return false;
+
+ if ((int)$user['twofa_enabled'] !== 1)
+ {
+ return false;
+ }
+
+ $to = $user['twofa_email'] ?: $user['login'];
+ if (!filter_var($to, FILTER_VALIDATE_EMAIL))
+ {
+ return false;
+ }
+
+ if ($resend && !empty($user['twofa_sent_at']))
+ {
+ $last = strtotime($user['twofa_sent_at']);
+ if ($last && (time() - $last) < 30)
+ {
+ return false;
+ }
+ }
+
+ $code = random_int(100000, 999999);
+ $hash = password_hash((string)$code, PASSWORD_DEFAULT);
+
+ self::update_by_id($userId, [
+ 'twofa_code_hash' => $hash,
+ 'twofa_expires_at' => date('Y-m-d H:i:s', time() + 10 * 60), // 10 minut
+ 'twofa_sent_at' => date('Y-m-d H:i:s'),
+ 'twofa_failed_attempts' => 0,
+ ]);
+
+ $subject = 'Twój kod logowania 2FA';
+ $body = "Twój kod logowania do panelu administratora: {$code}. Kod jest ważny przez 10 minut. Jeśli to nie Ty inicjowałeś logowanie – zignoruj tę wiadomość i poinformuj administratora.";
+
+ $sent = \S::send_email($to, $subject, $body);
+
+ if (!$sent) {
+ $headers = "MIME-Version: 1.0\r\n";
+ $headers .= "Content-type: text/plain; charset=UTF-8\r\n";
+ $headers .= "From: no-reply@" . ($_SERVER['HTTP_HOST'] ?? 'localhost') . "\r\n";
+ $encodedSubject = mb_encode_mimeheader($subject, 'UTF-8');
+
+ $sent = mail($to, $encodedSubject, $body, $headers);
+ }
+
+ return $sent;
+ }
+
+ static public function update_by_id(int $userId, array $data): bool
+ {
+ global $mdb;
+ return (bool)$mdb->update('pp_users', $data, ['id' => $userId]);
+ }
+
+ static public function verify_twofa_code(int $userId, string $code): bool
+ {
+ $user = self::get_by_id( $userId );
+ if (!$user) return false;
+
+ if ((int)$user['twofa_failed_attempts'] >= 5)
+ {
+ return false; // zbyt wiele prób
+ }
+
+ // sprawdź ważność
+ if (empty($user['twofa_expires_at']) || time() > strtotime($user['twofa_expires_at']))
+ {
+ // wyczyść po wygaśnięciu
+ self::update_by_id($userId, [
+ 'twofa_code_hash' => null,
+ 'twofa_expires_at' => null,
+ ]);
+ return false;
+ }
+
+ $ok = (!empty($user['twofa_code_hash']) && password_verify($code, $user['twofa_code_hash']));
+ if ($ok)
+ {
+ // sukces: czyścimy wszystko
+ self::update_by_id($userId, [
+ 'twofa_code_hash' => null,
+ 'twofa_expires_at' => null,
+ 'twofa_sent_at' => null,
+ 'twofa_failed_attempts' => 0,
+ 'last_logged' => date('Y-m-d H:i:s'),
+ ]);
+ return true;
+ }
+
+ // zła próba — inkrementacja
+ self::update_by_id($userId, [
+ 'twofa_failed_attempts' => (int)$user['twofa_failed_attempts'] + 1,
+ 'last_error_logged' => date('Y-m-d H:i:s'),
+ ]);
+ return false;
}
}
-?>
diff --git a/autoload/admin/view/class.Page.php b/autoload/admin/view/class.Page.php
index 23bcbce..c96583a 100644
--- a/autoload/admin/view/class.Page.php
+++ b/autoload/admin/view/class.Page.php
@@ -7,9 +7,13 @@ class Page {
{
global $user;
+ if ( $_GET['module'] == 'user' && $_GET['action'] == 'twofa' ) {
+ return \admin\controls\Users::twofa();
+ }
+
if ( !$user || !$user['admin'] )
return \admin\view\Users::login_form();
-
+
$tpl = new \Tpl;
$tpl -> content = \admin\Site::route();
return $tpl -> render( 'site/main-layout' );
diff --git a/autoload/class.Html.php b/autoload/class.Html.php
index ca9fb1a..d2500c9 100644
--- a/autoload/class.Html.php
+++ b/autoload/class.Html.php
@@ -1,5 +1,4 @@
-' . PHP_EOL;
-$site_map[$domain['domain']] .= '
' . PHP_EOL;
- $site_map[$domain['domain']] .= '' . PHP_EOL;
- $site_map[$domain['domain']] .= '' . $domain_prefix . '://' . $www . $domain['domain'] . ' ' . PHP_EOL;
- $site_map[$domain['domain']] .= '' . date('Y-m-d') . ' ' . PHP_EOL;
- $site_map[$domain['domain']] .= 'daily ' . PHP_EOL;
- $site_map[$domain['domain']] .= '1 ' . PHP_EOL;
- $site_map[$domain['domain']] .= ' ' . PHP_EOL;
- }
- }
- else
- {
- $site_map[$url] = '' . PHP_EOL;
- $site_map[$url] .= '' . PHP_EOL;
- $site_map[$url] .= '' . PHP_EOL;
- $site_map[$url] .= '' . $domain_prefix . '://' . $www . $url . ' ' . PHP_EOL;
- $site_map[$url] .= '' . date('Y-m-d') . ' ' . PHP_EOL;
- $site_map[$url] .= 'daily ' . PHP_EOL;
- $site_map[$url] .= '1 ' . PHP_EOL;
- $site_map[$url] .= ' ' . PHP_EOL;
- }
+ $site_map[$domain['domain']] .= '' . PHP_EOL;
+ $site_map[$domain['domain']] .= '' . PHP_EOL;
+ $site_map[$domain['domain']] .= '' . $domain_prefix . '://' . $www . $domain['domain'] . ' ' . PHP_EOL;
+ $site_map[$domain['domain']] .= '' . date('Y-m-d') . ' ' . PHP_EOL;
+ $site_map[$domain['domain']] .= 'daily ' . PHP_EOL;
+ $site_map[$domain['domain']] .= '1 ' . PHP_EOL;
+ $site_map[$domain['domain']] .= ' ' . PHP_EOL;
+ }
+ }
+ else
+ {
+ $site_map[$url] = '' . PHP_EOL;
+ $site_map[$url] .= '' . PHP_EOL;
+ $site_map[$url] .= '' . PHP_EOL;
+ $site_map[$url] .= '' . $domain_prefix . '://' . $www . $url . ' ' . PHP_EOL;
+ $site_map[$url] .= '' . date('Y-m-d') . ' ' . PHP_EOL;
+ $site_map[$url] .= 'daily ' . PHP_EOL;
+ $site_map[$url] .= '1 ' . PHP_EOL;
+ $site_map[$url] .= ' ' . PHP_EOL;
+ }
$htaccess_data = file_get_contents($dir . 'libraries/htaccess.conf');
/* cache */
if ($settings['htaccess_cache'])
{
- $htaccess_data = str_replace(
- '{HTACCESS_CACHE}',
- '' . PHP_EOL
- . 'AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml application/xhtml+xml text/css text/javascript application/javascript application/x-javascript' . PHP_EOL
- . ' ' . PHP_EOL
- . '' . PHP_EOL
- . 'ExpiresActive on' . PHP_EOL
- . 'ExpiresDefault "access plus 1 year"' . PHP_EOL
- . 'ExpiresByType text/css "access plus 1 year"' . PHP_EOL
- . 'ExpiresByType application/json "access plus 0 seconds"' . PHP_EOL
- . 'ExpiresByType application/xml "access plus 0 seconds"' . PHP_EOL
- . 'ExpiresByType text/xml "access plus 0 seconds"' . PHP_EOL
- . 'ExpiresByType image/x-icon "access plus 1 week"' . PHP_EOL
- . 'ExpiresByType text/x-component "access plus 1 year"' . PHP_EOL
- . 'ExpiresByType text/html "access plus 0 seconds"' . PHP_EOL
- . 'ExpiresByType application/javascript "access plus 1 year"' . PHP_EOL
- . 'ExpiresByType application/x-web-app-manifest+json "access plus 0 seconds"' . PHP_EOL
- . 'ExpiresByType text/cache-manifest "access plus 0 seconds"' . PHP_EOL
- . 'ExpiresByType audio/ogg "access plus 1 year"' . PHP_EOL
- . 'ExpiresByType image/gif "access plus 1 year"' . PHP_EOL
- . 'ExpiresByType image/jpeg "access plus 1 year"' . PHP_EOL
- . 'ExpiresByType image/webp "access plus 1 year"' . PHP_EOL
- . 'ExpiresByType image/png "access plus 1 year"' . PHP_EOL
- . 'ExpiresByType video/mp4 "access plus 1 year"' . PHP_EOL
- . 'ExpiresByType video/ogg "access plus 1 year"' . PHP_EOL
- . 'ExpiresByType video/webm "access plus 1 year"' . PHP_EOL
- . 'ExpiresByType application/atom+xml "access plus 1 hour"' . PHP_EOL
- . 'ExpiresByType application/rss+xml "access plus 1 hour"' . PHP_EOL
- . 'ExpiresByType application/font-woff "access plus 1 year"' . PHP_EOL
- . 'ExpiresByType application/vnd.ms-fontobject "access plus 1 year"' . PHP_EOL
- . 'ExpiresByType application/x-font-ttf "access plus 1 year"' . PHP_EOL
- . 'ExpiresByType font/opentype "access plus 1 year"' . PHP_EOL
- . 'ExpiresByType image/svg+xml "access plus 1 year"' . PHP_EOL
- . ' ',
- $htaccess_data
- );
+ $htaccess_data = str_replace(
+ '{HTACCESS_CACHE}',
+ '' . PHP_EOL
+ . 'AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml application/xhtml+xml text/css text/javascript application/javascript application/x-javascript' . PHP_EOL
+ . ' ' . PHP_EOL
+ . '' . PHP_EOL
+ . 'ExpiresActive on' . PHP_EOL
+ . 'ExpiresDefault "access plus 1 year"' . PHP_EOL
+ . 'ExpiresByType text/css "access plus 1 year"' . PHP_EOL
+ . 'ExpiresByType application/json "access plus 0 seconds"' . PHP_EOL
+ . 'ExpiresByType application/xml "access plus 0 seconds"' . PHP_EOL
+ . 'ExpiresByType text/xml "access plus 0 seconds"' . PHP_EOL
+ . 'ExpiresByType image/x-icon "access plus 1 week"' . PHP_EOL
+ . 'ExpiresByType text/x-component "access plus 1 year"' . PHP_EOL
+ . 'ExpiresByType text/html "access plus 0 seconds"' . PHP_EOL
+ . 'ExpiresByType application/javascript "access plus 1 year"' . PHP_EOL
+ . 'ExpiresByType application/x-web-app-manifest+json "access plus 0 seconds"' . PHP_EOL
+ . 'ExpiresByType text/cache-manifest "access plus 0 seconds"' . PHP_EOL
+ . 'ExpiresByType audio/ogg "access plus 1 year"' . PHP_EOL
+ . 'ExpiresByType image/gif "access plus 1 year"' . PHP_EOL
+ . 'ExpiresByType image/jpeg "access plus 1 year"' . PHP_EOL
+ . 'ExpiresByType image/webp "access plus 1 year"' . PHP_EOL
+ . 'ExpiresByType image/png "access plus 1 year"' . PHP_EOL
+ . 'ExpiresByType video/mp4 "access plus 1 year"' . PHP_EOL
+ . 'ExpiresByType video/ogg "access plus 1 year"' . PHP_EOL
+ . 'ExpiresByType video/webm "access plus 1 year"' . PHP_EOL
+ . 'ExpiresByType application/atom+xml "access plus 1 hour"' . PHP_EOL
+ . 'ExpiresByType application/rss+xml "access plus 1 hour"' . PHP_EOL
+ . 'ExpiresByType application/font-woff "access plus 1 year"' . PHP_EOL
+ . 'ExpiresByType application/vnd.ms-fontobject "access plus 1 year"' . PHP_EOL
+ . 'ExpiresByType application/x-font-ttf "access plus 1 year"' . PHP_EOL
+ . 'ExpiresByType font/opentype "access plus 1 year"' . PHP_EOL
+ . 'ExpiresByType image/svg+xml "access plus 1 year"' . PHP_EOL
+ . ' ',
+ $htaccess_data
+ );
}
else
{
- $htaccess_data = str_replace(
- '{HTACCESS_CACHE}',
- '' . PHP_EOL
- . 'Header set Cache-Control "no-cache, no-store, must-revalidate"' . PHP_EOL
- . 'Header set Pragma "no-cache"' . PHP_EOL
- . 'Header set Expires 0' . PHP_EOL
- . ' ',
- $htaccess_data
- );
+ $htaccess_data = str_replace(
+ '{HTACCESS_CACHE}',
+ '' . PHP_EOL
+ . 'Header set Cache-Control "no-cache, no-store, must-revalidate"' . PHP_EOL
+ . 'Header set Pragma "no-cache"' . PHP_EOL
+ . 'Header set Expires 0' . PHP_EOL
+ . ' ',
+ $htaccess_data
+ );
}
/* języki w domenie głównej */
$results = $mdb->select('pp_langs', ['id'], ['AND' => ['status' => 1, 'domain' => null], 'ORDER' => ['o' => 'ASC']]);
if (is_array($results)) foreach ($results as $row)
{
- $htaccess_data .= PHP_EOL . 'RewriteRule ^' . $row['id'] . '/$ index.php?a=change_language&id=' . $row['id'] . ' [L]';
+ $htaccess_data .= PHP_EOL . 'RewriteRule ^' . $row['id'] . '/$ index.php?a=change_language&id=' . $row['id'] . ' [L]';
}
$htaccess_data .= PHP_EOL;
@@ -682,215 +705,174 @@ $site_map[$domain['domain']] .= '' . PHP_EOL;
- }
-
- $site_map[$url_tmp] .= '' . date('Y-m-d') . ' ' . PHP_EOL;
- $site_map[$url_tmp] .= 'daily ' . PHP_EOL;
-
- $row['start'] ? $priority = 1 : $priority = 0.8;
-
- $site_map[$url_tmp] .= '' . $priority . ' ' . PHP_EOL;
- $site_map[$url_tmp] .= '' . PHP_EOL;
- }
-
- /* robotx.txt */
- if ($row2['noindex'] and $row2['page_type'] != 3)
- {
- $robots .= 'User-agent: GoogleBot' . PHP_EOL;
-
- if ($row2['seo_link'])
- {
- if ($settings['links_structure'])
- $seo = \admin\factory\Pages::google_url_preview($row2['page_id'], $row2['title'], $row[id], 0, 0, $row2['seo_link'], $language_link);
- else
- $seo = $language_link . \S::seo($row2['seo_link']);
-
- $robots .= 'Disallow: /' . $seo . '$' . PHP_EOL;
- $robots .= 'Disallow: /' . $seo . '-s-*' . PHP_EOL;
- }
- else
- {
- if ($settings['links_structure'])
- $seo = \admin\factory\Pages::google_url_preview($row2['page_id'], $row2['title'], $row['id'], 0, 0, $row2['seo_link'], $language_link);
- else
- $seo = $language_link . 's-' . $row2['page_id'] . '-' . \S::seo($row2['title']);
-
- $robots .= 'Disallow: /' . $seo . '$' . PHP_EOL;
- $robots .= 'Disallow: /' . $seo . '-s-*$' . PHP_EOL;
- }
- }
-
- /* htaccess */
- if ($row2['page_type'] != 3)
- {
- if ($row['start'] and $row2['start'])
- {
- $htaccess_data .= PHP_EOL . 'RewriteCond %{HTTP_HOST} ^' . $www . $url_tmp . '$ [NC]';
- $htaccess_data .= PHP_EOL . 'RewriteCond %{QUERY_STRING} ^(.*)(?:^|&)(utm_source|gclid|hash)=[^&]+(&.*)?';
- $htaccess_data .= PHP_EOL . 'RewriteRule ^$ index.php?a=page&id=' . $row2['page_id'] . '&lang=' . $row['id'] . '&%{QUERY_STRING} [L]' . PHP_EOL;
-
- if ($row2['seo_link'])
- {
- $htaccess_data .= PHP_EOL . 'RewriteCond %{HTTP_HOST} ^' . $www . $url_tmp . '$ [NC]';
- $htaccess_data .= PHP_EOL . 'RewriteCond %{REQUEST_URI} ^/' . \S::seo($row2['seo_link']) . '$';
- $htaccess_data .= PHP_EOL . 'RewriteRule ^(.*)$ ' . $domain_prefix . '://' . $www . $url_tmp . '/' . $language_link . ' [R=301,L]';
-
- $htaccess_data .= PHP_EOL . 'RewriteCond %{HTTP_HOST} ^' . $www . $url_tmp . '$ [NC]';
- $htaccess_data .= PHP_EOL . 'RewriteCond %{REQUEST_URI} ^/' . \S::seo($row2['seo_link']) . '-s-1$';
- $htaccess_data .= PHP_EOL . 'RewriteRule ^(.*)$ ' . $domain_prefix . '://' . $www . $url_tmp . '/' . $language_link . ' [R=301,L]';
- }
- else
- {
- $htaccess_data .= PHP_EOL . 'RewriteCond %{HTTP_HOST} ^' . $www . $url_tmp . '$ [NC]';
- $htaccess_data .= PHP_EOL . 'RewriteCond %{REQUEST_URI} ^/s-' . $row2['page_id'] . '-' . \S::seo($row2['title']) . '$';
- $htaccess_data .= PHP_EOL . 'RewriteRule ^(.*)$ ' . $domain_prefix . '://' . $www . $url_tmp . '/' . $language_link . ' [R=301,L]';
-
- $htaccess_data .= PHP_EOL . 'RewriteCond %{HTTP_HOST} ^' . $www . $url_tmp . '$ [NC]';
- $htaccess_data .= PHP_EOL . 'RewriteCond %{REQUEST_URI} ^/s-' . $row2['page_id'] . '-' . \S::seo($row2['title']) . '-s-1$';
- $htaccess_data .= PHP_EOL . 'RewriteRule ^(.*)$ ' . $domain_prefix . '://' . $www . $url_tmp . '/' . $language_link . ' [R=301,L]';
- }
-
- $htaccess_data .= PHP_EOL . 'RewriteCond %{HTTP_HOST} ^' . $www . $url_tmp . '$ [NC]';
- $htaccess_data .= PHP_EOL . 'RewriteCond %{REQUEST_URI} "^/$"';
- $htaccess_data .= PHP_EOL . 'RewriteRule ^$ index.php?a=page&id=' . $row2['page_id'] . '&lang=' . $row['id'] . ' [L]';
-
- $htaccess_data .= PHP_EOL;
- }
-
- if ($row2['seo_link'])
- {
- if ($settings['links_structure'])
- $seo = \admin\factory\Pages::google_url_preview($row2['page_id'], $row2['title'], $row[id], 0, 0, $row2['seo_link'], $language_link);
- else
- $seo = $language_link . \S::seo($row2['seo_link']);
-
- $htaccess_data .= PHP_EOL . 'RewriteCond %{HTTP_HOST} ^' . $www . $url_tmp . '$ [NC]';
- $htaccess_data .= PHP_EOL . 'RewriteCond %{QUERY_STRING} ^(.*)(?:^|&)(utm_source|gclid)=[^&]+(&.*)?';
- $htaccess_data .= PHP_EOL . 'RewriteRule ^' . $seo . '$ index.php?a=page&id=' . $row2['page_id'] . '&lang=' . $row['id'] . '&%{QUERY_STRING} [L]';
-
- $htaccess_data .= PHP_EOL . 'RewriteCond %{HTTP_HOST} ^' . $www . $url_tmp . '$ [NC]';
- $htaccess_data .= PHP_EOL . 'RewriteRule ^' . $seo . '-s-1$ ' . $seo . ' [R=301,L]';
-
- $htaccess_data .= PHP_EOL . 'RewriteCond %{HTTP_HOST} ^' . $www . $url_tmp . '$ [NC]';
- $htaccess_data .= PHP_EOL . 'RewriteCond %{QUERY_STRING} ^(.*)(?:^|&)(utm_source|gclid)=[^&]+(&.*)?';
- $htaccess_data .= PHP_EOL . 'RewriteRule ^' . $seo . '-s-([0-9]+)$ index.php?a=page&id=' . $row2['page_id'] . '&lang=' . $row['id'] . '&bs=$1&%{QUERY_STRING} [L]';
-
- $htaccess_data .= PHP_EOL . 'RewriteCond %{HTTP_HOST} ^' . $www . $url_tmp . '$ [NC]';
- $htaccess_data .= PHP_EOL . 'RewriteCond %{QUERY_STRING} !=""';
- $htaccess_data .= PHP_EOL . 'RewriteRule ' . $seo . ' %{REQUEST_URI}? [R=301,L]';
-
- $htaccess_data .= PHP_EOL . 'RewriteCond %{HTTP_HOST} ^' . $www . $url_tmp . '$ [NC]';
- $htaccess_data .= PHP_EOL . 'RewriteRule ^' . $seo . '$ index.php?a=page&id=' . $row2['page_id'] . '&lang=' . $row['id'] . ' [L]';
-
- $htaccess_data .= PHP_EOL . 'RewriteCond %{HTTP_HOST} ^' . $www . $url_tmp . '$ [NC]';
- $htaccess_data .= PHP_EOL . 'RewriteRule ^' . $seo . '-s-([0-9]+)$ index.php?a=page&id=' . $row2['page_id'] . '&lang=' . $row['id'] . '&bs=$1 [L]';
- }
- else
- {
- if ($settings['links_structure'])
- $seo = \admin\factory\Pages::google_url_preview($row2['page_id'], $row2['title'], $row['id'], 0, 0, $row2['seo_link'], $language_link);
- else
- $seo = $language_link . 's-' . $row2['page_id'] . '-' . \S::seo($row2['title']);
-
- $htaccess_data .= PHP_EOL . 'RewriteCond %{HTTP_HOST} ^' . $www . $url_tmp . '$ [NC]';
- $htaccess_data .= PHP_EOL . 'RewriteCond %{QUERY_STRING} ^(.*)(?:^|&)(utm_source|gclid)=[^&]+(&.*)?';
- $htaccess_data .= PHP_EOL . 'RewriteRule ^' . $seo . '$ index.php?a=page&id=' . $row2['page_id'] . '&lang=' . $row['id'] . '&%{QUERY_STRING} [L]';
-
- $htaccess_data .= PHP_EOL . 'RewriteCond %{HTTP_HOST} ^' . $www . $url_tmp . '$ [NC]';
- $htaccess_data .= PHP_EOL . 'RewriteRule ^' . $seo . '-s-1$ ' . $seo . ' [R=301,L]';
-
- $htaccess_data .= PHP_EOL . 'RewriteCond %{HTTP_HOST} ^' . $www . $url_tmp . '$ [NC]';
- $htaccess_data .= PHP_EOL . 'RewriteCond %{QUERY_STRING} ^(.*)(?:^|&)(utm_source|gclid)=[^&]+(&.*)?';
- $htaccess_data .= PHP_EOL . 'RewriteRule ^' . $seo . '-s-([0-9]+)$ index.php?a=page&id=' . $row2['page_id'] . '&lang=' . $row['id'] . '&bs=$1&%{QUERY_STRING} [L]';
-
- $htaccess_data .= PHP_EOL . 'RewriteCond %{HTTP_HOST} ^' . $www . $url_tmp . '$ [NC]';
- $htaccess_data .= PHP_EOL . 'RewriteCond %{QUERY_STRING} !=""';
- $htaccess_data .= PHP_EOL . 'RewriteRule ' . $seo . ' %{REQUEST_URI}? [R=301,L]';
-
- $htaccess_data .= PHP_EOL . 'RewriteCond %{HTTP_HOST} ^' . $www . $url_tmp . '$ [NC]';
- $htaccess_data .= PHP_EOL . 'RewriteRule ^' . $seo . '$ index.php?a=page&id=' . $row2['page_id'] . '&lang=' . $row['id'] . ' [L]';
-
- $htaccess_data .= PHP_EOL . 'RewriteCond %{HTTP_HOST} ^' . $www . $url_tmp . '$ [NC]';
- $htaccess_data .= PHP_EOL . 'RewriteRule ^' . $seo . '-s-([0-9]+)$ index.php?a=page&id=' . $row2['page_id'] . '&lang=' . $row['id'] . '&bs=$1 [L]';
- }
- $htaccess_data .= PHP_EOL;
- }
- }
}
$results2 = $mdb->select(
- 'pp_articles_langs',
- ['[><]pp_articles'=> ['article_id' => 'id']],
+ 'pp_articles_langs',
+ ['[><]pp_articles' => ['article_id' => 'id']],
['seo_link', 'title', 'article_id', 'noindex', 'copy_from', 'block_direct_access'],
['AND' => ['status' => 1, 'lang_id' => $row['id']]]
- );
- if (is_array($results2)) foreach ($results2 as $row2)
- {
+ );
+ if (is_array($results2)) foreach ($results2 as $row2)
+ {
$domain = \S::get_language_domain($row['id']);
if ($row2['copy_from'] != null)
{
- $results_tmp = $mdb->get(
- 'pp_articles_langs',
- [
- 'seo_link',
- 'title'
- ],
- [
- 'AND' => [
- 'article_id' => $row2['article_id'],
- 'lang_id' => $row2['copy_from']
- ]
- ]
- );
- $row2['seo_link'] = $results_tmp['seo_link'];
- $row2['title'] = $results_tmp['title'];
+ $results_tmp = $mdb->get(
+ 'pp_articles_langs',
+ [
+ 'seo_link',
+ 'title'
+ ],
+ [
+ 'AND' => [
+ 'article_id' => $row2['article_id'],
+ 'lang_id' => $row2['copy_from']
+ ]
+ ]
+ );
+ $row2['seo_link'] = $results_tmp['seo_link'];
+ $row2['title'] = $results_tmp['title'];
}
/* sitemap */
if (!$row2['block_direct_access'] and $row2['title'])
{
- $site_map[$url_tmp] .= '' . PHP_EOL;
+ $site_map[$url_tmp] .= '' . PHP_EOL;
if ($row2['seo_link'])
- $site_map[$url_tmp] .= '' . $domain_prefix . '://' . $www . $url_tmp . '/' . $language_link . \S::seo($row2['seo_link']) . ' ' . PHP_EOL;
+ $site_map[$url_tmp] .= '' . $domain_prefix . '://' . $www . $url_tmp . '/' . $language_link . \S::seo($row2['seo_link']) . ' ' . PHP_EOL;
else
- $site_map[$url_tmp] .= '' . $domain_prefix . '://' . $www . $url_tmp . '/' . $language_link . 'a-' . $row2['article_id'] . '-' . self::seo($row2['title']) . ' ' . PHP_EOL;
+ $site_map[$url_tmp] .= '' . $domain_prefix . '://' . $www . $url_tmp . '/' . $language_link . 'a-' . $row2['article_id'] . '-' . self::seo($row2['title']) . ' ' . PHP_EOL;
$site_map[$url_tmp] .= '' . date('Y-m-d') . ' ' . PHP_EOL;
$site_map[$url_tmp] .= 'daily ' . PHP_EOL;
$site_map[$url_tmp] .= '0.6 ' . PHP_EOL;
@@ -900,419 +882,433 @@ $site_map[$domain['domain']] .= 'query('SELECT '
+ . 'name, tag_id '
+ . 'FROM '
+ . 'pp_tags AS pt '
+ . 'INNER JOIN '
+ . 'pp_articles_tags AS pat ON pat.tag_id = pt.id '
+ . 'GROUP BY '
+ . 'tag_id')->fetchAll();
+ if (is_array($results) and !empty($results)) foreach ($results as $row)
+ {
+ $htaccess_data .= PHP_EOL . 'RewriteCond %{QUERY_STRING} !=""';
+ $htaccess_data .= PHP_EOL . 'RewriteRule tag/' . \S::seo( $row['name'] ) . '(|/) %{REQUEST_URI}? [R=301,L]';
+ $htaccess_data .= PHP_EOL . 'RewriteRule ^tag/' . \S::seo( $row['name'] ) . '(|/)$ index.php?tag=' . $row['tag_id'] . ' [L]';
+ }
- $htaccess_data .= PHP_EOL . 'RewriteCond %{HTTP_HOST} ^' . $domain . '$ [NC]';
- $htaccess_data .= PHP_EOL . 'RewriteRule ^' . $language_link . 'a-' . $row2['article_id'] . '-' . \S::seo($row2['title']) . '$ index.php?article=' . $row2['article_id'] . '&lang=' . $row['id'] . ' [L]';
- }
- $htaccess_data .= PHP_EOL;
- }
- }
- }
+ $results = $mdb->get('pp_settings', 'value', ['param' => 'htaccess']);
+ if ($results)
+ $htaccess_data .= PHP_EOL . $results;
- $results = $mdb->query('SELECT '
- . 'name, tag_id '
- . 'FROM '
- . 'pp_tags AS pt '
- . 'INNER JOIN '
- . 'pp_articles_tags AS pat ON pat.tag_id = pt.id '
- . 'GROUP BY '
- . 'tag_id')->fetchAll();
- if (is_array($results) and !empty($results)) foreach ($results as $row)
- {
- $htaccess_data .= PHP_EOL . 'RewriteCond %{QUERY_STRING} !=""';
- $htaccess_data .= PHP_EOL . 'RewriteRule tag,' . \S::seo($row['name']) . ' %{REQUEST_URI}? [R=301,L]';
- $htaccess_data .= PHP_EOL . 'RewriteRule ^tag,' . \S::seo($row['name']) . '$ index.php?tag=' . $row['tag_id'] . ' [L]';
- }
+ if (file_exists('../libraries/htaccess.ini'))
+ $htaccess_data .= PHP_EOL . file_get_contents('../libraries/htaccess.ini');
- $results = $mdb->get('pp_settings', 'value', ['param' => 'htaccess']);
- if ($results)
- $htaccess_data .= PHP_EOL . $results;
+ $results = $mdb->get('pp_settings', 'value', ['param' => 'robots']);
+ if ($results)
+ $robots .= PHP_EOL . $results;
- if (file_exists('../libraries/htaccess.ini'))
- $htaccess_data .= PHP_EOL . file_get_contents('../libraries/htaccess.ini');
-
- $results = $mdb->get('pp_settings', 'value', ['param' => 'robots']);
- if ($results)
- $robots .= PHP_EOL . $results;
-
- if (is_array($available_domains) and !empty($available_domains))
- {
- foreach ($available_domains as $domain)
+ if (is_array($available_domains) and !empty($available_domains))
+ {
+ foreach ($available_domains as $domain)
$site_map[$domain['domain']] .= ' ';
+ }
+ else
+ $site_map[$url] .= ' ';
+
+ if ($settings['ssl'])
+ {
+ if ($settings['link_version'])
+ {
+ $htaccess_data = str_replace(
+ '{REDIRECT}',
+ 'RewriteCond %{HTTP_HOST} !^www\.' . PHP_EOL
+ . 'RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=permanent]' . PHP_EOL
+
+ . 'RewriteCond %{SERVER_PORT} !=443' . PHP_EOL
+ . 'RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=permanent]' . PHP_EOL
+
+ . '## Remove trailing slash' . PHP_EOL
+ . 'RewriteCond %{REQUEST_FILENAME} !-d [NC]' . PHP_EOL
+ . 'RewriteCond %{REQUEST_URI} !^/admin/(.*) [NC]' . PHP_EOL
+ . 'RewriteRule ^(.*)/$ https://%{HTTP_HOST}/$1 [L,R=301]',
+ $htaccess_data
+ );
+ }
+ else
+ {
+ $htaccess_data = str_replace(
+ '{REDIRECT}',
+ 'RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]' . PHP_EOL
+ . 'RewriteRule ^(.*)$ https://%1/$1 [R=301,L]' . PHP_EOL
+ . 'RewriteCond %{SERVER_PORT} !=443' . PHP_EOL
+ . 'RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=permanent]' . PHP_EOL
+
+ . '## Remove trailing slash' . PHP_EOL
+ . 'RewriteCond %{REQUEST_FILENAME} !-d [NC]' . PHP_EOL
+ . 'RewriteCond %{REQUEST_URI} !^/admin/(.*) [NC]' . PHP_EOL
+ . 'RewriteRule ^(.*)/$ https://%{HTTP_HOST}/$1 [L,R=301]',
+ $htaccess_data
+ );
+ }
+ }
+ else
+ {
+ if ($settings['link_version'])
+ {
+ $htaccess_data = str_replace(
+ '{REDIRECT}',
+ 'RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC]' . PHP_EOL
+ . 'RewriteRule ^(.*)$ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=permanent]' . PHP_EOL
+
+ . 'RewriteCond %{SERVER_PORT} =443' . PHP_EOL
+ . 'RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=permanent]' . PHP_EOL
+
+ . '## Remove trailing slash' . PHP_EOL
+ . 'RewriteCond %{REQUEST_FILENAME} !-d [NC]' . PHP_EOL
+ . 'RewriteCond %{REQUEST_URI} !^/admin/(.*) [NC]' . PHP_EOL
+ . 'RewriteRule ^(.*)/$ http://%{HTTP_HOST}/$1 [L,R=301]',
+ $htaccess_data
+ );
+ }
+ else
+ {
+ $htaccess_data = str_replace(
+ '{REDIRECT}',
+ 'RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]' . PHP_EOL
+ . 'RewriteRule ^(.*)$ http://%1/$1 [R=301,L]' . PHP_EOL
+ . 'RewriteCond %{SERVER_PORT} =443' . PHP_EOL
+ . 'RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=permanent]' . PHP_EOL
+
+ . '## Remove trailing slash' . PHP_EOL
+ . 'RewriteCond %{REQUEST_FILENAME} !-d [NC]' . PHP_EOL
+ . 'RewriteCond %{REQUEST_URI} !^/admin/(.*) [NC]' . PHP_EOL
+ . 'RewriteRule ^(.*)/$ http://%{HTTP_HOST}/$1 [L,R=301]',
+ $htaccess_data
+ );
+ }
+ }
+
+ $additional_classes = file_get_contents('../libraries/additional-classes.ini');
+ $additional_classes = explode(PHP_EOL, $additional_classes);
+ $additional_classes = array_filter($additional_classes);
+ if (is_array($additional_classes) and !empty($additional_classes))
+ {
+ foreach ($additional_classes as $class)
+ {
+ $classes .= 'RewriteCond %{REQUEST_URI} ^/' . trim($class) . '/(.*) [NC]' . PHP_EOL;
+ $classes .= 'RewriteRule ^([^/]*)/([^/]*)(|/([^/]*))$ index.php?module=$1&action=$2&$4 [L]' . PHP_EOL;
+ }
+ }
+ $htaccess_data = str_replace('{ADDITIONAL_CLASSES}', $classes, $htaccess_data);
+
+ /* pozostałe linki */
+ $htaccess_data .= PHP_EOL;
+ $htaccess_data .= 'RewriteRule ^newsletter/signin$ index.php?module=newsletter&action=signin [L]' . PHP_EOL;
+ $htaccess_data .= 'RewriteRule ^newsletter/confirm/hash=(.*)$ index.php?module=newsletter&action=confirm&hash=$1 [L]' . PHP_EOL;
+ $htaccess_data .= 'RewriteRule ^newsletter/unsubscribe/hash=(.*)$ index.php?module=newsletter&action=unsubscribe&hash=$1 [L]' . PHP_EOL;
+
+ /* pixieset */
+ $results = $mdb->select('pp_articles', 'id', ['pixieset' => 1]);
+ if (is_array($results) and count($results))
+ {
+ $pixieset = 'RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?' . $url_tmp . ' [NC]' . PHP_EOL;
+ $pixieset .= 'RewriteCond %{REQUEST_URI} ^(';
+ foreach ($results as $row)
+ {
+ $pixieset .= '/upload/article_images/article_' . $row . '/';
+ if ($row != end($results))
+ $pixieset .= '|';
+ }
+ $pixieset .= ') [NC]' . PHP_EOL . 'RewriteRule \.(jpg|jpeg|png|gif)$ - [NC,F,L]' . PHP_EOL;
+
+ $htaccess_data = str_replace('{PIXIESET]', $pixieset, $htaccess_data);
+ }
+ else
+ {
+ $htaccess_data = str_replace('{PIXIESET]', '', $htaccess_data);
+ }
+
+ $fp = fopen($dir . '.htaccess', 'w');
+ fwrite($fp, $htaccess_data);
+ fclose($fp);
+
+ $class = '\admin\factory\Sitemap';
+ $action = 'sitemap';
+
+ if (class_exists($class) and method_exists(new $class, $action))
+ $site_map = call_user_func_array(array($class, $action), array($site_map, $available_domains, $domain_prefix, $www, $url));
+
+ if (is_array($available_domains) and !empty($available_domains))
+ {
+ foreach ($available_domains as $domain)
+ {
+ $fp = fopen($dir . 'sitemap_' . \S::seo($domain['domain']) . '.xml', 'w');
+ fwrite($fp, $site_map[$domain['domain']]);
+ fclose($fp);
+ }
+ }
+ else
+ {
+ $fp = fopen($dir . 'sitemap.xml', 'w');
+ fwrite($fp, $site_map[$url]);
+ fclose($fp);
+ }
+
+ $fp = fopen($dir . 'robots.txt', 'w');
+ fwrite($fp, $robots);
+ fclose($fp);
}
- else
- $site_map[$url] .= '
- ';
-if ($settings['ssl'])
-{
-if ($settings['link_version'])
-{
-$htaccess_data = str_replace(
-'{REDIRECT}',
-'RewriteCond %{HTTP_HOST} !^www\.' . PHP_EOL
-. 'RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=permanent]' . PHP_EOL
+ public static function seo( $val, $delete_rhombs = false )
+ {
+ $array_rep1 = array('*', '_', ' ', '+', '"', "'", '?', '-', ',', '!', '~', '<', '>', '@', '#', '$', '%', '^', '&', '*' . '(', ')' . '-', '=', '\\', '|', '[', ']', ':', '(', ')');
+ $array_rep2 = array('-', '-', '-', '-', '', '', '', '-', '-', '', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '', '-', '-', '-', '-', '-', '-', '-', '-');
+ $val = self::noPl($val);
+ $val = str_replace($array_rep1, $array_rep2, $val);
+ if ($delete_rhombs)
+ $val = str_replace('/', '', $val);
-. 'RewriteCond %{SERVER_PORT} !=443' . PHP_EOL
-. 'RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=permanent]' . PHP_EOL
+ $val = strtolower($val);
+ $val = preg_replace('/(-){2,}/', '-', $val);
+ $val = ltrim($val, '-');
+ $val = rtrim($val, '-');
+ return $val;
+ }
-. '## Remove trailing slash' . PHP_EOL
-. 'RewriteCond %{REQUEST_FILENAME} !-d [NC]' . PHP_EOL
-. 'RewriteCond %{REQUEST_URI} !^/admin/(.*) [NC]' . PHP_EOL
-. 'RewriteRule ^(.*)/$ https://%{HTTP_HOST}/$1 [L,R=301]',
-$htaccess_data
-);
-}
-else
-{
-$htaccess_data = str_replace(
-'{REDIRECT}',
-'RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]' . PHP_EOL
-. 'RewriteRule ^(.*)$ https://%1/$1 [R=301,L]' . PHP_EOL
-. 'RewriteCond %{SERVER_PORT} !=443' . PHP_EOL
-. 'RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=permanent]' . PHP_EOL
+ public static function noPL($string)
+ {
+ $chars = array( // Decompositions for Latin-1 Supplement chr(195).chr(128)=> 'A', chr(195).chr(129) => 'A',
+ chr(195) . chr(130) => 'A', chr(195) . chr(131) => 'A',
+ chr(195) . chr(132) => 'A', chr(195) . chr(133) => 'A',
+ chr(195) . chr(135) => 'C', chr(195) . chr(136) => 'E',
+ chr(195) . chr(137) => 'E', chr(195) . chr(138) => 'E',
+ chr(195) . chr(139) => 'E', chr(195) . chr(140) => 'I',
+ chr(195) . chr(141) => 'I', chr(195) . chr(142) => 'I',
+ chr(195) . chr(143) => 'I', chr(195) . chr(145) => 'N',
+ chr(195) . chr(146) => 'O', chr(195) . chr(147) => 'O',
+ chr(195) . chr(148) => 'O', chr(195) . chr(149) => 'O',
+ chr(195) . chr(150) => 'O', chr(195) . chr(153) => 'U',
+ chr(195) . chr(154) => 'U', chr(195) . chr(155) => 'U',
+ chr(195) . chr(156) => 'U', chr(195) . chr(157) => 'Y',
+ chr(195) . chr(159) => 's', chr(195) . chr(160) => 'a',
+ chr(195) . chr(161) => 'a', chr(195) . chr(162) => 'a',
+ chr(195) . chr(163) => 'a', chr(195) . chr(164) => 'a',
+ chr(195) . chr(165) => 'a', chr(195) . chr(167) => 'c',
+ chr(195) . chr(168) => 'e', chr(195) . chr(169) => 'e',
+ chr(195) . chr(170) => 'e', chr(195) . chr(171) => 'e',
+ chr(195) . chr(172) => 'i', chr(195) . chr(173) => 'i',
+ chr(195) . chr(174) => 'i', chr(195) . chr(175) => 'i',
+ chr(195) . chr(177) => 'n', chr(195) . chr(178) => 'o',
+ chr(195) . chr(179) => 'o', chr(195) . chr(180) => 'o',
+ chr(195) . chr(181) => 'o', chr(195) . chr(182) => 'o',
+ chr(195) . chr(182) => 'o', chr(195) . chr(185) => 'u',
+ chr(195) . chr(186) => 'u', chr(195) . chr(187) => 'u',
+ chr(195) . chr(188) => 'u', chr(195) . chr(189) => 'y',
+ chr(195) . chr(191) => 'y',
+ // Decompositions for Latin Extended-A
+ chr(196) . chr(128) => 'A', chr(196) . chr(129) => 'a',
+ chr(196) . chr(130) => 'A', chr(196) . chr(131) => 'a',
+ chr(196) . chr(132) => 'A', chr(196) . chr(133) => 'a',
+ chr(196) . chr(134) => 'C', chr(196) . chr(135) => 'c',
+ chr(196) . chr(136) => 'C', chr(196) . chr(137) => 'c',
+ chr(196) . chr(138) => 'C', chr(196) . chr(139) => 'c',
+ chr(196) . chr(140) => 'C', chr(196) . chr(141) => 'c',
+ chr(196) . chr(142) => 'D', chr(196) . chr(143) => 'd',
+ chr(196) . chr(144) => 'D', chr(196) . chr(145) => 'd',
+ chr(196) . chr(146) => 'E', chr(196) . chr(147) => 'e',
+ chr(196) . chr(148) => 'E', chr(196) . chr(149) => 'e',
+ chr(196) . chr(150) => 'E', chr(196) . chr(151) => 'e',
+ chr(196) . chr(152) => 'E', chr(196) . chr(153) => 'e',
+ chr(196) . chr(154) => 'E', chr(196) . chr(155) => 'e',
+ chr(196) . chr(156) => 'G', chr(196) . chr(157) => 'g',
+ chr(196) . chr(158) => 'G', chr(196) . chr(159) => 'g',
+ chr(196) . chr(160) => 'G', chr(196) . chr(161) => 'g',
+ chr(196) . chr(162) => 'G', chr(196) . chr(163) => 'g',
+ chr(196) . chr(164) => 'H', chr(196) . chr(165) => 'h',
+ chr(196) . chr(166) => 'H', chr(196) . chr(167) => 'h',
+ chr(196) . chr(168) => 'I', chr(196) . chr(169) => 'i',
+ chr(196) . chr(170) => 'I', chr(196) . chr(171) => 'i',
+ chr(196) . chr(172) => 'I', chr(196) . chr(173) => 'i',
+ chr(196) . chr(174) => 'I', chr(196) . chr(175) => 'i',
+ chr(196) . chr(176) => 'I', chr(196) . chr(177) => 'i',
+ chr(196) . chr(178) => 'IJ', chr(196) . chr(179) => 'ij',
+ chr(196) . chr(180) => 'J', chr(196) . chr(181) => 'j',
+ chr(196) . chr(182) => 'K', chr(196) . chr(183) => 'k',
+ chr(196) . chr(184) => 'k', chr(196) . chr(185) => 'L',
+ chr(196) . chr(186) => 'l', chr(196) . chr(187) => 'L',
+ chr(196) . chr(188) => 'l', chr(196) . chr(189) => 'L',
+ chr(196) . chr(190) => 'l', chr(196) . chr(191) => 'L',
+ chr(197) . chr(128) => 'l', chr(197) . chr(129) => 'L',
+ chr(197) . chr(130) => 'l', chr(197) . chr(131) => 'N',
+ chr(197) . chr(132) => 'n', chr(197) . chr(133) => 'N',
+ chr(197) . chr(134) => 'n', chr(197) . chr(135) => 'N',
+ chr(197) . chr(136) => 'n', chr(197) . chr(137) => 'N',
+ chr(197) . chr(138) => 'n', chr(197) . chr(139) => 'N',
+ chr(197) . chr(140) => 'O', chr(197) . chr(141) => 'o',
+ chr(197) . chr(142) => 'O', chr(197) . chr(143) => 'o',
+ chr(197) . chr(144) => 'O', chr(197) . chr(145) => 'o',
+ chr(197) . chr(146) => 'OE', chr(197) . chr(147) => 'oe',
+ chr(197) . chr(148) => 'R', chr(197) . chr(149) => 'r',
+ chr(197) . chr(150) => 'R', chr(197) . chr(151) => 'r',
+ chr(197) . chr(152) => 'R', chr(197) . chr(153) => 'r',
+ chr(197) . chr(154) => 'S', chr(197) . chr(155) => 's',
+ chr(197) . chr(156) => 'S', chr(197) . chr(157) => 's',
+ chr(197) . chr(158) => 'S', chr(197) . chr(159) => 's',
+ chr(197) . chr(160) => 'S', chr(197) . chr(161) => 's',
+ chr(197) . chr(162) => 'T', chr(197) . chr(163) => 't',
+ chr(197) . chr(164) => 'T', chr(197) . chr(165) => 't',
+ chr(197) . chr(166) => 'T', chr(197) . chr(167) => 't',
+ chr(197) . chr(168) => 'U', chr(197) . chr(169) => 'u',
+ chr(197) . chr(170) => 'U', chr(197) . chr(171) => 'u',
+ chr(197) . chr(172) => 'U', chr(197) . chr(173) => 'u',
+ chr(197) . chr(174) => 'U', chr(197) . chr(175) => 'u',
+ chr(197) . chr(176) => 'U', chr(197) . chr(177) => 'u',
+ chr(197) . chr(178) => 'U', chr(197) . chr(179) => 'u',
+ chr(197) . chr(180) => 'W', chr(197) . chr(181) => 'w',
+ chr(197) . chr(182) => 'Y', chr(197) . chr(183) => 'y',
+ chr(197) . chr(184) => 'Y', chr(197) . chr(185) => 'Z',
+ chr(197) . chr(186) => 'z', chr(197) . chr(187) => 'Z',
+ chr(197) . chr(188) => 'z', chr(197) . chr(189) => 'Z',
+ chr(197) . chr(190) => 'z', chr(197) . chr(191) => 's'
+ );
-. '## Remove trailing slash' . PHP_EOL
-. 'RewriteCond %{REQUEST_FILENAME} !-d [NC]' . PHP_EOL
-. 'RewriteCond %{REQUEST_URI} !^/admin/(.*) [NC]' . PHP_EOL
-. 'RewriteRule ^(.*)/$ https://%{HTTP_HOST}/$1 [L,R=301]',
-$htaccess_data
-);
-}
-}
-else
-{
-if ($settings['link_version'])
-{
-$htaccess_data = str_replace(
-'{REDIRECT}',
-'RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC]' . PHP_EOL
-. 'RewriteRule ^(.*)$ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=permanent]' . PHP_EOL
+ $string = strtr($string, $chars);
-. 'RewriteCond %{SERVER_PORT} =443' . PHP_EOL
-. 'RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=permanent]' . PHP_EOL
+ $table = array(
+ "А" => "a", "Б" => "b", "В" => "v", "Г" => "g", "Д" => "d",
+ "Е" => "e", "Ё" => "yo", "Ж" => "zh", "З" => "z", "И" => "i",
+ "Й" => "j", "К" => "k", "Л" => "l", "М" => "m", "Н" => "n",
+ "О" => "o", "П" => "p", "Р" => "r", "С" => "s", "Т" => "t",
+ "У" => "u", "Ф" => "f", "Х" => "kh", "Ц" => "ts", "Ч" => "ch",
+ "Ш" => "sh", "Щ" => "sch", "Ъ" => "", "Ы" => "y", "Ь" => "",
+ "Э" => "e", "Ю" => "yu", "Я" => "ya", "а" => "a", "б" => "b",
+ "в" => "v", "г" => "g", "д" => "d", "е" => "e", "ё" => "yo",
+ "ж" => "zh", "з" => "z", "и" => "i", "й" => "j", "к" => "k",
+ "л" => "l", "м" => "m", "н" => "n", "о" => "o", "п" => "p",
+ "р" => "r", "с" => "s", "т" => "t", "у" => "u", "ф" => "f",
+ "х" => "kh", "ц" => "ts", "ч" => "ch", "ш" => "sh", "щ" => "sch",
+ "ъ" => "", "ы" => "y", "ь" => "", "э" => "e", "ю" => "yu",
+ "я" => "ya", " " => "-", "." => "", "," => "",
+ ":" => "", ";" => "", "—" => "", "–" => "-"
+ );
-. '## Remove trailing slash' . PHP_EOL
-. 'RewriteCond %{REQUEST_FILENAME} !-d [NC]' . PHP_EOL
-. 'RewriteCond %{REQUEST_URI} !^/admin/(.*) [NC]' . PHP_EOL
-. 'RewriteRule ^(.*)/$ http://%{HTTP_HOST}/$1 [L,R=301]',
-$htaccess_data
-);
-}
-else
-{
-$htaccess_data = str_replace(
-'{REDIRECT}',
-'RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]' . PHP_EOL
-. 'RewriteRule ^(.*)$ http://%1/$1 [R=301,L]' . PHP_EOL
-. 'RewriteCond %{SERVER_PORT} =443' . PHP_EOL
-. 'RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=permanent]' . PHP_EOL
+ $string = strtr($string, $table);
-. '## Remove trailing slash' . PHP_EOL
-. 'RewriteCond %{REQUEST_FILENAME} !-d [NC]' . PHP_EOL
-. 'RewriteCond %{REQUEST_URI} !^/admin/(.*) [NC]' . PHP_EOL
-. 'RewriteRule ^(.*)/$ http://%{HTTP_HOST}/$1 [L,R=301]',
-$htaccess_data
-);
-}
-}
-
-$additional_classes = file_get_contents('../libraries/additional-classes.ini');
-$additional_classes = explode(PHP_EOL, $additional_classes);
-$additional_classes = array_filter($additional_classes);
-if (is_array($additional_classes) and !empty($additional_classes))
-{
-foreach ($additional_classes as $class)
-{
-$classes .= 'RewriteCond %{REQUEST_URI} ^/' . trim($class) . '/(.*) [NC]' . PHP_EOL;
-$classes .= 'RewriteRule ^([^/]*)/([^/]*)(|/([^/]*))$ index.php?module=$1&action=$2&$4 [L]' . PHP_EOL;
-}
-}
-$htaccess_data = str_replace('{ADDITIONAL_CLASSES}', $classes, $htaccess_data);
-
-/* pozostałe linki */
-$htaccess_data .= PHP_EOL;
-$htaccess_data .= 'RewriteRule ^newsletter/signin$ index.php?module=newsletter&action=signin [L]' . PHP_EOL;
-$htaccess_data .= 'RewriteRule ^newsletter/confirm/hash=(.*)$ index.php?module=newsletter&action=confirm&hash=$1 [L]' . PHP_EOL;
-$htaccess_data .= 'RewriteRule ^newsletter/unsubscribe/hash=(.*)$ index.php?module=newsletter&action=unsubscribe&hash=$1 [L]' . PHP_EOL;
-
-/* pixieset */
-$results = $mdb->select('pp_articles', 'id', ['pixieset' => 1]);
-if (is_array($results) and count($results))
-{
-$pixieset = 'RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?' . $url_tmp . ' [NC]' . PHP_EOL;
-$pixieset .= 'RewriteCond %{REQUEST_URI} ^(';
-foreach ($results as $row)
-{
-$pixieset .= '/upload/article_images/article_' . $row . '/';
-if ($row != end($results))
-$pixieset .= '|';
-}
-$pixieset .= ') [NC]' . PHP_EOL . 'RewriteRule \.(jpg|jpeg|png|gif)$ - [NC,F,L]' . PHP_EOL;
-
-$htaccess_data = str_replace('{PIXIESET]', $pixieset, $htaccess_data);
-}
-else
-{
-$htaccess_data = str_replace('{PIXIESET]', '', $htaccess_data);
-}
-
-$fp = fopen($dir . '.htaccess', 'w');
-fwrite($fp, $htaccess_data);
-fclose($fp);
-
-$class = '\admin\factory\Sitemap';
-$action = 'sitemap';
-
-if (class_exists($class) and method_exists(new $class, $action))
-$site_map = call_user_func_array(array($class, $action), array($site_map, $available_domains, $domain_prefix, $www, $url));
-
-if (is_array($available_domains) and !empty($available_domains))
-{
-foreach ($available_domains as $domain)
-{
-$fp = fopen($dir . 'sitemap_' . \S::seo($domain['domain']) . '.xml', 'w');
-fwrite($fp, $site_map[$domain['domain']]);
-fclose($fp);
-}
-}
-else
-{
-$fp = fopen($dir . 'sitemap.xml', 'w');
-fwrite($fp, $site_map[$url]);
-fclose($fp);
-}
-
-$fp = fopen($dir . 'robots.txt', 'w');
-fwrite($fp, $robots);
-fclose($fp);
-}
-
-public static function seo($val, $delete_rhombs = false)
-{
-$array_rep1 = array('*', '_', ' ', '+', '"', "'", '?', '-', ',', '!', '~', '<', '>' , '@' , '#' , '$' , '%' , '^' , '&' , '*' . '(' , ')' . '-' , '=' , '\\' , '|' , '[' , ']' , ':' , '(' , ')' ); $array_rep2=array('-', '-' , '-' , '-' , '' , '' , '' , '-' , '-' , '' , '-' , '-' , '-' , '-' , '-' , '-' , '-' , '-' , '-' , '-' , '-' , '-' , '' , '-' , '-' , '-' , '-' , '-' , '-' , '-' , '-' ); $val=self::noPl($val); $val=str_replace($array_rep1, $array_rep2, $val); if ($delete_rhombs) $val=str_replace('/', '' , $val); $val=strtolower($val); $val=preg_replace('/(-){2,}/', '-' , $val); $val=ltrim($val, '-' ); $val=rtrim($val, '-' ); return $val; } public static function noPL($string) { $chars=array( // Decompositions for Latin-1 Supplement chr(195).chr(128)=> 'A', chr(195).chr(129) => 'A',
- chr(195) . chr(130) => 'A', chr(195) . chr(131) => 'A',
- chr(195) . chr(132) => 'A', chr(195) . chr(133) => 'A',
- chr(195) . chr(135) => 'C', chr(195) . chr(136) => 'E',
- chr(195) . chr(137) => 'E', chr(195) . chr(138) => 'E',
- chr(195) . chr(139) => 'E', chr(195) . chr(140) => 'I',
- chr(195) . chr(141) => 'I', chr(195) . chr(142) => 'I',
- chr(195) . chr(143) => 'I', chr(195) . chr(145) => 'N',
- chr(195) . chr(146) => 'O', chr(195) . chr(147) => 'O',
- chr(195) . chr(148) => 'O', chr(195) . chr(149) => 'O',
- chr(195) . chr(150) => 'O', chr(195) . chr(153) => 'U',
- chr(195) . chr(154) => 'U', chr(195) . chr(155) => 'U',
- chr(195) . chr(156) => 'U', chr(195) . chr(157) => 'Y',
- chr(195) . chr(159) => 's', chr(195) . chr(160) => 'a',
- chr(195) . chr(161) => 'a', chr(195) . chr(162) => 'a',
- chr(195) . chr(163) => 'a', chr(195) . chr(164) => 'a',
- chr(195) . chr(165) => 'a', chr(195) . chr(167) => 'c',
- chr(195) . chr(168) => 'e', chr(195) . chr(169) => 'e',
- chr(195) . chr(170) => 'e', chr(195) . chr(171) => 'e',
- chr(195) . chr(172) => 'i', chr(195) . chr(173) => 'i',
- chr(195) . chr(174) => 'i', chr(195) . chr(175) => 'i',
- chr(195) . chr(177) => 'n', chr(195) . chr(178) => 'o',
- chr(195) . chr(179) => 'o', chr(195) . chr(180) => 'o',
- chr(195) . chr(181) => 'o', chr(195) . chr(182) => 'o',
- chr(195) . chr(182) => 'o', chr(195) . chr(185) => 'u',
- chr(195) . chr(186) => 'u', chr(195) . chr(187) => 'u',
- chr(195) . chr(188) => 'u', chr(195) . chr(189) => 'y',
- chr(195) . chr(191) => 'y',
- // Decompositions for Latin Extended-A
- chr(196) . chr(128) => 'A', chr(196) . chr(129) => 'a',
- chr(196) . chr(130) => 'A', chr(196) . chr(131) => 'a',
- chr(196) . chr(132) => 'A', chr(196) . chr(133) => 'a',
- chr(196) . chr(134) => 'C', chr(196) . chr(135) => 'c',
- chr(196) . chr(136) => 'C', chr(196) . chr(137) => 'c',
- chr(196) . chr(138) => 'C', chr(196) . chr(139) => 'c',
- chr(196) . chr(140) => 'C', chr(196) . chr(141) => 'c',
- chr(196) . chr(142) => 'D', chr(196) . chr(143) => 'd',
- chr(196) . chr(144) => 'D', chr(196) . chr(145) => 'd',
- chr(196) . chr(146) => 'E', chr(196) . chr(147) => 'e',
- chr(196) . chr(148) => 'E', chr(196) . chr(149) => 'e',
- chr(196) . chr(150) => 'E', chr(196) . chr(151) => 'e',
- chr(196) . chr(152) => 'E', chr(196) . chr(153) => 'e',
- chr(196) . chr(154) => 'E', chr(196) . chr(155) => 'e',
- chr(196) . chr(156) => 'G', chr(196) . chr(157) => 'g',
- chr(196) . chr(158) => 'G', chr(196) . chr(159) => 'g',
- chr(196) . chr(160) => 'G', chr(196) . chr(161) => 'g',
- chr(196) . chr(162) => 'G', chr(196) . chr(163) => 'g',
- chr(196) . chr(164) => 'H', chr(196) . chr(165) => 'h',
- chr(196) . chr(166) => 'H', chr(196) . chr(167) => 'h',
- chr(196) . chr(168) => 'I', chr(196) . chr(169) => 'i',
- chr(196) . chr(170) => 'I', chr(196) . chr(171) => 'i',
- chr(196) . chr(172) => 'I', chr(196) . chr(173) => 'i',
- chr(196) . chr(174) => 'I', chr(196) . chr(175) => 'i',
- chr(196) . chr(176) => 'I', chr(196) . chr(177) => 'i',
- chr(196) . chr(178) => 'IJ', chr(196) . chr(179) => 'ij',
- chr(196) . chr(180) => 'J', chr(196) . chr(181) => 'j',
- chr(196) . chr(182) => 'K', chr(196) . chr(183) => 'k',
- chr(196) . chr(184) => 'k', chr(196) . chr(185) => 'L',
- chr(196) . chr(186) => 'l', chr(196) . chr(187) => 'L',
- chr(196) . chr(188) => 'l', chr(196) . chr(189) => 'L',
- chr(196) . chr(190) => 'l', chr(196) . chr(191) => 'L',
- chr(197) . chr(128) => 'l', chr(197) . chr(129) => 'L',
- chr(197) . chr(130) => 'l', chr(197) . chr(131) => 'N',
- chr(197) . chr(132) => 'n', chr(197) . chr(133) => 'N',
- chr(197) . chr(134) => 'n', chr(197) . chr(135) => 'N',
- chr(197) . chr(136) => 'n', chr(197) . chr(137) => 'N',
- chr(197) . chr(138) => 'n', chr(197) . chr(139) => 'N',
- chr(197) . chr(140) => 'O', chr(197) . chr(141) => 'o',
- chr(197) . chr(142) => 'O', chr(197) . chr(143) => 'o',
- chr(197) . chr(144) => 'O', chr(197) . chr(145) => 'o',
- chr(197) . chr(146) => 'OE', chr(197) . chr(147) => 'oe',
- chr(197) . chr(148) => 'R', chr(197) . chr(149) => 'r',
- chr(197) . chr(150) => 'R', chr(197) . chr(151) => 'r',
- chr(197) . chr(152) => 'R', chr(197) . chr(153) => 'r',
- chr(197) . chr(154) => 'S', chr(197) . chr(155) => 's',
- chr(197) . chr(156) => 'S', chr(197) . chr(157) => 's',
- chr(197) . chr(158) => 'S', chr(197) . chr(159) => 's',
- chr(197) . chr(160) => 'S', chr(197) . chr(161) => 's',
- chr(197) . chr(162) => 'T', chr(197) . chr(163) => 't',
- chr(197) . chr(164) => 'T', chr(197) . chr(165) => 't',
- chr(197) . chr(166) => 'T', chr(197) . chr(167) => 't',
- chr(197) . chr(168) => 'U', chr(197) . chr(169) => 'u',
- chr(197) . chr(170) => 'U', chr(197) . chr(171) => 'u',
- chr(197) . chr(172) => 'U', chr(197) . chr(173) => 'u',
- chr(197) . chr(174) => 'U', chr(197) . chr(175) => 'u',
- chr(197) . chr(176) => 'U', chr(197) . chr(177) => 'u',
- chr(197) . chr(178) => 'U', chr(197) . chr(179) => 'u',
- chr(197) . chr(180) => 'W', chr(197) . chr(181) => 'w',
- chr(197) . chr(182) => 'Y', chr(197) . chr(183) => 'y',
- chr(197) . chr(184) => 'Y', chr(197) . chr(185) => 'Z',
- chr(197) . chr(186) => 'z', chr(197) . chr(187) => 'Z',
- chr(197) . chr(188) => 'z', chr(197) . chr(189) => 'Z',
- chr(197) . chr(190) => 'z', chr(197) . chr(191) => 's'
- );
-
- $string = strtr($string, $chars);
-
- $table = array(
- "А" => "a", "Б" => "b", "В" => "v", "Г" => "g", "Д" => "d",
- "Е" => "e", "Ё" => "yo", "Ж" => "zh", "З" => "z", "И" => "i",
- "Й" => "j", "К" => "k", "Л" => "l", "М" => "m", "Н" => "n",
- "О" => "o", "П" => "p", "Р" => "r", "С" => "s", "Т" => "t",
- "У" => "u", "Ф" => "f", "Х" => "kh", "Ц" => "ts", "Ч" => "ch",
- "Ш" => "sh", "Щ" => "sch", "Ъ" => "", "Ы" => "y", "Ь" => "",
- "Э" => "e", "Ю" => "yu", "Я" => "ya", "а" => "a", "б" => "b",
- "в" => "v", "г" => "g", "д" => "d", "е" => "e", "ё" => "yo",
- "ж" => "zh", "з" => "z", "и" => "i", "й" => "j", "к" => "k",
- "л" => "l", "м" => "m", "н" => "n", "о" => "o", "п" => "p",
- "р" => "r", "с" => "s", "т" => "t", "у" => "u", "ф" => "f",
- "х" => "kh", "ц" => "ts", "ч" => "ch", "ш" => "sh", "щ" => "sch",
- "ъ" => "", "ы" => "y", "ь" => "", "э" => "e", "ю" => "yu",
- "я" => "ya", " " => "-", "." => "", "," => "",
- ":" => "", ";" => "", "—" => "", "–" => "-"
- );
-
- $string = strtr($string, $table);
-
- return $string;
+ return $string;
}
public static function delete_cache()
{
- \S::delete_dir('../cache/');
- \S::delete_dir('../temp/');
- \S::delete_dir('temp/');
+ \S::delete_dir('../cache/');
+ \S::delete_dir('../temp/');
+ \S::delete_dir('temp/');
}
public static function delete_dir($dir)
{
- if (is_file($dir))
- return @unlink($dir);
+ if (is_file($dir))
+ return @unlink($dir);
- else if (is_dir($dir))
- {
- $scan = glob(rtrim($dir, '/') . '/*');
+ else if (is_dir($dir))
+ {
+ $scan = glob(rtrim($dir, '/') . '/*');
- if (is_array($scan))
- foreach ($scan as $index => $path)
- self::delete_dir($path);
+ if (is_array($scan))
+ foreach ($scan as $index => $path)
+ self::delete_dir($path);
- if (is_dir($dir) && self::is_empty_dir($dir) and $dir != '../temp/')
- return @rmdir($dir);
- }
+ if (is_dir($dir) && self::is_empty_dir($dir) and $dir != '../temp/')
+ return @rmdir($dir);
+ }
}
public static function is_empty_dir($dir)
{
- return (($files = @scandir($dir)) && count($files) <= 2); } public static function email_check($email) { return filter_var($email, FILTER_VALIDATE_EMAIL); } public static function send_email($email, $subject, $text, $replay='' , $file='' ) { global $settings; if (file_exists('libraries/phpmailer/class.phpmailer.php')) require_once 'libraries/phpmailer/class.phpmailer.php' ; if (file_exists('libraries/phpmailer/class.smtp.php')) require_once 'libraries/phpmailer/class.smtp.php' ; if (file_exists('../libraries/phpmailer/class.phpmailer.php')) require_once '../libraries/phpmailer/class.phpmailer.php' ; if (file_exists('../libraries/phpmailer/class.smtp.php')) require_once '../libraries/phpmailer/class.smtp.php' ; if ($email and $subject) { $mail=new PHPMailer(); $mail->IsSMTP();
- $mail->SMTPAuth = true;
- $mail->Host = $settings['email_host'];
- $mail->Port = $settings['email_port'];
- $mail->Username = $settings['email_login'];
- $mail->Password = $settings['email_password'];
- $mail->CharSet = "UTF-8";
- $mail->SMTPOptions = array(
- 'ssl' => array(
- 'verify_peer' => false,
- 'verify_peer_name' => false,
- 'allow_self_signed' => true
- )
- );
+ return (($files = @scandir($dir)) && count($files) <= 2);
+ }
+ public static function email_check($email)
+ {
+ return filter_var($email, FILTER_VALIDATE_EMAIL);
+ }
+ public static function send_email( $email, $subject, $text, $replay = '', $file = '' )
+ {
+ global $settings;
- if (self::email_check($replay))
+ if ( file_exists('libraries/phpmailer/class.phpmailer.php') ) require_once 'libraries/phpmailer/class.phpmailer.php';
+ if ( file_exists('libraries/phpmailer/class.smtp.php') ) require_once 'libraries/phpmailer/class.smtp.php';
+ if ( file_exists('../libraries/phpmailer/class.phpmailer.php') ) require_once '../libraries/phpmailer/class.phpmailer.php';
+ if ( file_exists('../libraries/phpmailer/class.smtp.php') ) require_once '../libraries/phpmailer/class.smtp.php';
+ if ( $email and $subject )
{
- $mail->AddReplyTo($replay, $replay);
- $mail->SetFrom($settings['contact_email'], $settings['contact_email']);
- }
- else
- {
- $mail->AddReplyTo($settings['contact_email'], $settings['firm_name']);
- $mail->SetFrom($settings['contact_email'], $settings['firm_name']);
- }
+ $mail = new PHPMailer();
+ $mail->IsSMTP();
+ $mail->SMTPAuth = true;
+ $mail->Host = $settings['email_host'];
+ $mail->Port = $settings['email_port'];
+ $mail->Username = $settings['email_login'];
+ $mail->Password = $settings['email_password'];
+ $mail->CharSet = "UTF-8";
+ $mail->SMTPOptions = array(
+ 'ssl' => array(
+ 'verify_peer' => false,
+ 'verify_peer_name' => false,
+ 'allow_self_signed' => true
+ )
+ );
- $mail->AddAddress($email, '');
- $mail->Subject = $subject;
- $mail->Body = $text;
- if (is_array($file))
- {
- foreach ($file as $file_tmp)
- {
- if (file_exists($file_tmp))
- $mail->AddAttachment($file_tmp);
+ if (self::email_check($replay))
+ {
+ $mail->AddReplyTo($replay, $replay);
+ $mail->SetFrom($settings['contact_email'], $settings['contact_email']);
+ }
+ else
+ {
+ $mail->AddReplyTo($settings['contact_email'], $settings['firm_name']);
+ $mail->SetFrom($settings['contact_email'], $settings['firm_name']);
+ }
+
+ $mail->AddAddress($email, '');
+ $mail->Subject = $subject;
+ $mail->Body = $text;
+ if (is_array($file))
+ {
+ foreach ($file as $file_tmp)
+ {
+ if (file_exists($file_tmp))
+ $mail->AddAttachment($file_tmp);
+ }
+ }
+ else
+ {
+ if (file_exists($file))
+ $mail->AddAttachment($file);
+ }
+ $mail->IsHTML(true);
+ return $mail -> Send();
}
- }
- else
- {
- if (file_exists($file))
- $mail->AddAttachment($file);
- }
- $mail->IsHTML(true);
- return $mail->Send();
- }
- return false;
- }
- }
\ No newline at end of file
+ return true;
+ }
+}
diff --git a/autoload/front/factory/class.Articles.php b/autoload/front/factory/class.Articles.php
index 4d0abbc..0d78935 100644
--- a/autoload/front/factory/class.Articles.php
+++ b/autoload/front/factory/class.Articles.php
@@ -1,165 +1,183 @@
]*)>(.*?)<\/\1>/', $content, $matches, PREG_SET_ORDER);
+ // Tylko h1–h3
+ preg_match_all('/<(h[1-3])([^>]*)>(.*?)<\/\1>/i', $content, $matches, PREG_SET_ORDER);
- $firstLevel = true;
+ if (empty($matches))
+ {
+ return '';
+ }
- foreach ($matches as $match) {
- $level = intval(substr($match[1], 1));
+ foreach ($matches as $match)
+ {
+ $level = (int)substr($match[1], 1);
+ $text = trim($match[3]);
- while ($level < count($currentLevel)) {
- $result .= '';
- array_pop($currentLevel);
+ // Pobierz lub wygeneruj ID
+ preg_match('/\sid=["\']?([^"\']+)["\']?/', $match[2], $idMatch);
+ $id = isset($idMatch[1])
+ ? $idMatch[1]
+ : strtolower(preg_replace('/[^a-z0-9]+/u', '-', html_entity_decode(strip_tags($text), ENT_QUOTES, 'UTF-8')));
+
+ if ($prevLevel === 0)
+ {
+ $prevLevel = $level;
+ $stack[] = $level;
+ }
+
+ if ($level > $prevLevel)
+ {
+ for ($i = $prevLevel; $i < $level; $i++)
+ {
+ $result .= '';
+ $stack[] = $i + 1;
}
-
- if ($level > count($currentLevel)) {
- while ($level > count($currentLevel)) {
- if (count($currentLevel) > 0 || $firstLevel) {
- $result .= '';
- $firstLevel = false;
- }
- array_push($currentLevel, 0);
- }
- $result .= '';
- } else {
- $result .= ' ';
+ }
+ elseif ($level < $prevLevel)
+ {
+ for ($i = $prevLevel; $i > $level; $i--)
+ {
+ $result .= ' ';
+ array_pop($stack);
}
+ $result .= '';
+ }
+ else
+ {
+ $result .= '';
+ }
- $currentLevel[count($currentLevel) - 1]++;
-
- preg_match('/\sid="([^"]*)"/', $match[2], $idMatches);
- $id = isset($idMatches[1]) ? $idMatches[1] : '';
-
- $result .= sprintf(
- '%s ',
- urlencode(strtolower($id)),
- $match[3]
- );
+ $result .= '' . $text . ' ';
+ $prevLevel = $level;
}
- while (!empty($currentLevel)) {
- $result .= ' ';
- array_pop($currentLevel);
+ // Zamknij pozostałe listy
+ while (!empty($stack))
+ {
+ $result .= '';
+ array_pop($stack);
}
- if (substr($result, 0, 8) === '') {
- return substr($result, 4, -5);
- } else {
- return $result;
- }
+ return '' . $result . ' ';
}
// funkcja wywoływana dla każdego dopasowania do wyrażenia regularnego
- static public function processHeaders( $matches )
+ 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 );
+ if ($id_attr_pos === false)
+ { // jeśli nie ma atrybutu id
+ $id = \S::seo($content);
$attrs .= sprintf(' id="%s"', $id);
}
- $html = sprintf( '%s ', $level, $attrs, $content, $level );
+ $html = sprintf('%s ', $level, $attrs, $content, $level);
return $html;
}
- static public function generateHeadersIds( $text )
+ static public function generateHeadersIds($text)
{
$pattern = '/(.*?)<\/h\1>/si';
- $text = preg_replace_callback( $pattern, array(__CLASS__, 'processHeaders'), $text );
+ $text = preg_replace_callback($pattern, array(__CLASS__, 'processHeaders'), $text);
return $text;
}
- public static function pixieset_save_favorite_images( $hash )
+ public static function pixieset_save_favorite_images($hash)
{
global $mdb, $settings;
- \S::delete_dir( 'temp/' );
+ \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' );
+ $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 = 'Witaj, ';
$text .= 'Użytkownik zatwierdził listę wybranych przez siebie zdjęć. ';
$text .= 'Poniżej znajdziesz nazwy wybranych zdjęć.
';
$text .= '';
- if ( is_array( $article['images'] ) ) foreach ( $article['images'] as $image )
- if ( $image['favorite'] )
- $text .= '' . basename( $image['src'] ) . ' ';
+ if (is_array($article['images'])) foreach ($article['images'] as $image)
+ if ($image['favorite'])
+ $text .= '' . basename($image['src']) . ' ';
$text .= ' ';
- \S::send_email( $settings['contact_email'], 'Powiadomienie ze strony: ' . $_SERVER['SERVER_NAME'], $text );
+ \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 )
+ 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 )
+ $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 ] ] );
+ $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/' );
+ \S::delete_dir('temp/');
return !$status;
}
}
- public static function article_password( $article_id )
+ public static function article_password($article_id)
{
global $mdb;
- return $mdb -> get( 'pp_articles', 'password', [ 'id' => $article_id ] );
+ return $mdb->get('pp_articles', 'password', ['id' => $article_id]);
}
- public static function articles_by_tags( $tag_id, $lang_id )
+ public static function articles_by_tags($tag_id, $lang_id)
{
global $mdb;
- if ( !$articles = \Cache::fetch( "articles_by_tags:$tag_id:$lang_id" ) )
+ 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 );
+ $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 );
+ \Cache::store("articles_by_tags:$tag_id:$lang_id", $articles);
}
return $articles;
}
- public static function tag_details( $tag_id )
+ public static function tag_details($tag_id)
{
global $mdb;
- if ( !$tag = \Cache::fetch( "tag_details:$tag_id" ) )
+ if (!$tag = \Cache::fetch("tag_details:$tag_id"))
{
- $tag = $mdb -> get( 'pp_tags', '*', [ 'id' => (int)$tag_id ] );
+ $tag = $mdb->get('pp_tags', '*', ['id' => (int)$tag_id]);
- \Cache::store( "tag_details:$tag_id", $tag );
+ \Cache::store("tag_details:$tag_id", $tag);
}
return $tag;
}
@@ -168,276 +186,294 @@ class Articles
{
global $mdb;
- if ( !$tags = \Cache::fetch( 'tags' ) )
+ 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();
+ $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 );
+ \Cache::store('tags', $tags);
}
return $tags;
}
- public static function articles_by_date( $month, $year, $lang_id )
+ public static function articles_by_date($month, $year, $lang_id)
{
global $mdb;
- if ( !$articles = \Cache::fetch( "articles_by_date:$month:$year:$lang_id" ) )
+ 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 );
+ $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 );
+ \Cache::store("articles_by_date:$month:$year:$lang_id", $articles);
}
return $articles;
}
- public static function news( $page_id, $limit = 6, $lang_id )
+ public static function news($page_id, $limit = 6, $lang_id)
{
- $sort = \front\factory\Pages::page_sort( $page_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 );
+ $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 )
+ public static function get_image($article, $skip_entry = false)
{
- if ( $article['language']['main_image'] )
+ if ($article['language']['main_image'])
{
- if ( file_exists( substr( $article['language']['main_image'], 1, strlen( $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 )
+ 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 )
+ $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 ) ) ) )
+ $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 )
+ $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 ) ) ) )
+ $src = $img->getAttribute('src');
+ if (file_exists(substr($src, 1, strlen($src))))
return $src;
}
- if ( $article['images'] )
+ if ($article['images'])
return $article['images'][0]['src'];
return false;
}
- public static function article_noindex( $article_id )
+ public static function article_noindex($article_id)
{
global $mdb, $lang;
- if ( !$noindex = \Cache::fetch( "article_noindex:$article_id:" . $lang[0] ) )
+ 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] ] ] );
+ $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 );
+ \Cache::store("article_noindex:$article_id:" . $lang[0], $noindex);
}
return $noindex;
}
- public static function page_articles( $page, $lang_id, $bs )
+ 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'] );
+ $count = \front\factory\Articles::page_articles_count($page['id'], $lang_id);
+ $ls = ceil($count / $page['articles_limit']);
- if ( $bs < 1 )
+ if ($bs < 1)
$bs = 1;
- else if ( $bs > $ls )
+ else if ($bs > $ls)
$bs = $ls;
- $from = $page['articles_limit'] * ( $bs - 1 );
+ $from = $page['articles_limit'] * ($bs - 1);
- if ( $from < 0 )
+ 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['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 )
+ public static function article_details($article_id, $lang_id)
{
global $mdb;
- if ( !$article = \Cache::fetch( "article_details:$lang_id:$article_id" ) )
+ if (!$article = \Cache::fetch("article_details:$lang_id:$article_id"))
{
- $article = $mdb -> get( 'pp_articles', '*', [ 'id' => (int)$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 )
+ $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'] )
+ 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 )
+ $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 )
+ 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'] );
+ $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 )
+ 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'] );
+ $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 )
+ $article['images'] = $mdb->select('pp_articles_images', '*', ['article_id' => (int)$article_id, 'ORDER' => ['o' => 'ASC', 'id' => 'ASC'] ] );
+ // załączniki
+ $article['files'] = $mdb -> select( 'pp_articles_files', '*', [ 'article_id' => (int)$article_id, 'ORDER' => [ 'o' => 'ASC', 'id' => 'ASC'] ] );
+ $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'];
+ if (!$row['language_id'])
+ $params[$row['name']] = $row['value'];
else
- $params[ $row['name'] ][$row['language_id']] = $row['value'];
+ $params[$row['name']][$row['language_id']] = $row['value'];
}
$article['params'] = $params;
- \Cache::store( "article_details:$lang_id:$article_id", $article );
+ \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 )
+ public static function artciles_id($page_id, $lang_id, $articles_limit, $sort_type, $from)
{
global $mdb;
- switch ( $sort_type )
+ 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;
+ 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" ) )
+ 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 )
+ $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 );
+ \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 )
+ public static function page_articles_count($page_id, $lang_id)
{
global $mdb;
- if ( !$output = \Cache::fetch( "page_articles_count:$page_id:$lang_id" ) )
+ 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();
+ $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 );
+ \Cache::store("page_articles_count:$page_id:$lang_id", $output);
}
return $output;
}
-}
\ No newline at end of file
+}
diff --git a/autoload/front/factory/class.Settings.php b/autoload/front/factory/class.Settings.php
index 9d37999..7a04550 100644
--- a/autoload/front/factory/class.Settings.php
+++ b/autoload/front/factory/class.Settings.php
@@ -6,19 +6,19 @@ 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;
diff --git a/autoload/front/view/91hero.php b/autoload/front/view/91hero.php
deleted file mode 100644
index e69de29..0000000
diff --git a/autoload/front/view/class.Articles.php b/autoload/front/view/class.Articles.php
index 8be6203..a06af80 100644
--- a/autoload/front/view/class.Articles.php
+++ b/autoload/front/view/class.Articles.php
@@ -10,7 +10,7 @@ class Articles
$tpl -> $key = $val;
return $tpl -> render( 'articles/password-view' );
}
-
+
public static function map( $settings, $map_counter )
{
$tpl = new \Tpl;
@@ -18,34 +18,39 @@ class Articles
$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 )
+
+ public static function news( $page_id, $articles, $template = '' )
{
- $tpl = new \Tpl;
- $tpl -> page_id = $page_id;
- $tpl -> articles = $articles;
- return $tpl -> render( 'articles/news' );
+ if ( $template )
+ $tpl = $template;
+ else
+ $tpl = 'articles/news';
+
+ return \Tpl::view( $tpl, [
+ 'page_id' => $page_id,
+ 'articles' => $articles
+ ] );
}
-
+
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;
@@ -53,26 +58,26 @@ class Articles
$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;
@@ -81,24 +86,24 @@ class Articles
$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;
@@ -107,28 +112,29 @@ class Articles
$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' );
+ {
+ $out .= \Tpl::view( 'articles/article-full', [
+ 'article' => $article_details,
+ 'table_of_contents' => \front\factory\Articles::generateTableOfContents( $article_details['language']['text'] )
+ ] );
}
}
-
+
if ( $results['ls'] > 1 )
{
$tpl = new \Tpl;
@@ -137,7 +143,7 @@ class Articles
$tpl -> page = $page;
$out .= $tpl -> render( 'site/pager' );
}
-
+
return $out;
}
}
\ No newline at end of file
diff --git a/autoload/front/view/class.Site.php b/autoload/front/view/class.Site.php
index d7b8304..afafe2c 100644
--- a/autoload/front/view/class.Site.php
+++ b/autoload/front/view/class.Site.php
@@ -1,4 +1,5 @@
', ' ', $html );
+ if ($settings['google_search_console'])
+ $html = str_replace('', ' ', $html);
- if ( \S::get_session( 'contrast' ) )
- $html = str_replace( '', ' ', $html );
+ if (\S::get_session('contrast'))
+ $html = str_replace('', ' ', $html);
- if ( $settings['facebook_link'] )
- $html = str_replace( '