Add table of contents generation and header ID processing to Articles class
- Implemented `generateTableOfContents` method to create a structured table of contents from article content. - Added `processHeaders` method to ensure headers have unique IDs for linking. - Updated `generateHeadersIds` to apply ID generation to headers in article content. - Modified `article_full` method to include table of contents in rendered articles. - Enhanced `submenu_details` and `subpages` methods in Menu class to support language ID. - Updated caching mechanisms to include language ID for subpages and menu details. - Refactored various methods in Articles view class for improved readability and consistency. - Added new sftp configuration file for deployment settings.
This commit is contained in:
12
.vscode/sftp.json
vendored
Normal file
12
.vscode/sftp.json
vendored
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"name": "inwestprofil.fr",
|
||||||
|
"host": "inwestprofil.pl",
|
||||||
|
"protocol": "ftp",
|
||||||
|
"port": 21,
|
||||||
|
"username": "ftp@inwestprofil.fr",
|
||||||
|
"password": "4wCFuWYSQlckbqGBT",
|
||||||
|
"remotePath": "/public_html",
|
||||||
|
"uploadOnSave": false,
|
||||||
|
"useTempFile": false,
|
||||||
|
"openSsh": false
|
||||||
|
}
|
||||||
@@ -2,7 +2,6 @@
|
|||||||
<script type="text/javascript" src="/libraries/ckeditor/adapters/jquery.js"></script>
|
<script type="text/javascript" src="/libraries/ckeditor/adapters/jquery.js"></script>
|
||||||
<script type="text/javascript" src="/libraries/jquery/sortable/sortable.js"></script>
|
<script type="text/javascript" src="/libraries/jquery/sortable/sortable.js"></script>
|
||||||
<?
|
<?
|
||||||
;
|
|
||||||
global $db, $settings;
|
global $db, $settings;
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
@@ -120,12 +119,19 @@ ob_start();
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<? if ( is_array( $this -> authors ) ): foreach ( $this -> authors as $author ): $authors[ $author['id'] ] = $author['author']; endforeach; endif;?>
|
<?
|
||||||
|
$authors[0] = '--- wybierz autora ---';
|
||||||
|
if ( is_array( $this -> authors ) ):
|
||||||
|
foreach ( $this -> authors as $author ):
|
||||||
|
$authors[ $author['id'] ] = $author['author'];
|
||||||
|
endforeach;
|
||||||
|
endif;
|
||||||
|
?>
|
||||||
<?= \Html::select( [
|
<?= \Html::select( [
|
||||||
'label' => 'Autor',
|
'label' => 'Autor',
|
||||||
'name' => "id_author",
|
'name' => "id_author",
|
||||||
'id' => 'id_author',
|
'id' => 'id_author',
|
||||||
'values' => array_merge( [ '0' => '--- wybierz autora ---' ], $authors ),
|
'values' => $authors,
|
||||||
'value' => $this -> article['id_author']
|
'value' => $this -> article['id_author']
|
||||||
] );?>
|
] );?>
|
||||||
<?= \Html::input_switch(
|
<?= \Html::input_switch(
|
||||||
@@ -149,6 +155,11 @@ ob_start();
|
|||||||
'checked' => $this -> article['show_title'] == 1 ? true : false
|
'checked' => $this -> article['show_title'] == 1 ? true : false
|
||||||
)
|
)
|
||||||
);?>
|
);?>
|
||||||
|
<?= \Html::input_switch( [
|
||||||
|
'label' => 'Pokaż spis treści',
|
||||||
|
'name' => 'show_table_of_contents',
|
||||||
|
'checked' => $this -> article['show_table_of_contents'] == 1 ? true : false
|
||||||
|
] );?>
|
||||||
<?= \Html::input_switch(
|
<?= \Html::input_switch(
|
||||||
array(
|
array(
|
||||||
'label' => 'Pokaż datę dodania',
|
'label' => 'Pokaż datę dodania',
|
||||||
|
|||||||
@@ -351,6 +351,14 @@ ob_start();
|
|||||||
'value' => $this -> settings['link_version'] ? 1 : 0
|
'value' => $this -> settings['link_version'] ? 1 : 0
|
||||||
] );?>
|
] );?>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<?= \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
|
||||||
|
] );?>
|
||||||
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<?= \Html::select( [
|
<?= \Html::select( [
|
||||||
'label' => "Newsletter",
|
'label' => "Newsletter",
|
||||||
|
|||||||
@@ -207,7 +207,7 @@
|
|||||||
<? endif;?>
|
<? endif;?>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<? if ( \admin\factory\Users::check_privileges( 'seo_additional', $user[ 'id' ] ) ):?>
|
<? if ( \admin\factory\Users::check_privileges( 'seo_administration', $user[ 'id' ] ) ):?>
|
||||||
<a href="/admin/seo_additional/main_view/">
|
<a href="/admin/seo_additional/main_view/">
|
||||||
<img src="/admin/css/icons/settings-20-filled.svg">Dodatkowe ustawienia SEO
|
<img src="/admin/css/icons/settings-20-filled.svg">Dodatkowe ustawienia SEO
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
24
ajax.php
24
ajax.php
@@ -74,23 +74,27 @@ if ( \S::get( 'a' ) == 'widget-phone-now' )
|
|||||||
if ( \S::get( 'a' ) == 'contact_form' )
|
if ( \S::get( 'a' ) == 'contact_form' )
|
||||||
{
|
{
|
||||||
$response = [ 'status' => 'error' ];
|
$response = [ 'status' => 'error' ];
|
||||||
|
$email = trim( (string) \S::get( 'email' ) );
|
||||||
|
$phone = trim( (string) \S::get( 'phone' ) );
|
||||||
|
$subject = trim( (string) \S::get( 'subject' ) );
|
||||||
|
$text = trim( (string) \S::get( 'text' ) );
|
||||||
|
|
||||||
if ( \S::get( 'email' ) )
|
if ( $email || $phone )
|
||||||
{
|
{
|
||||||
if ( \S::send_email(
|
if ( \S::send_email(
|
||||||
$settings['contact_email'],
|
$settings['contact_email'],
|
||||||
\S::get( 'subject' ),
|
$subject,
|
||||||
'<p>Nr telefonu: ' . \S::get( 'phone' ) . '</p>'
|
'<p>Nr telefonu: ' . $phone . '</p>'
|
||||||
. '<p>Email: ' . \S::get( 'email' ) . '</p>'
|
. '<p>Email: ' . $email . '</p>'
|
||||||
. '<p>' . \S::get( 'text' ) . '</p>',
|
. '<p>' . $text . '</p>',
|
||||||
\S::get( 'email' )
|
$email
|
||||||
) )
|
) )
|
||||||
{
|
{
|
||||||
$mdb -> insert( 'pp_contact_emails', [
|
$mdb -> insert( 'pp_contact_emails', [
|
||||||
'email' => \S::get( 'email' ),
|
'email' => $email,
|
||||||
'phone' => \S::get('phone' ),
|
'phone' => $phone,
|
||||||
'title' => \S::get( 'subject' ),
|
'title' => $subject,
|
||||||
'mail' => \S::get( 'text' ),
|
'mail' => $text,
|
||||||
'add_date' => date("Y-m-d, H:i")
|
'add_date' => date("Y-m-d, H:i")
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ class Articles
|
|||||||
$values['params'] = $params;
|
$values['params'] = $params;
|
||||||
|
|
||||||
if ( $id = \admin\factory\Articles::article_save(
|
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['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['seo_link'], $values['meta_title'], $values['meta_description'], $values['meta_keywords'], $values['layout_id'],
|
$values['show_date_modify'], $values['seo_link'], $values['meta_title'], $values['meta_description'], $values['meta_keywords'], $values['layout_id'],
|
||||||
$values['pages'], $values['noindex'], $values['repeat_entry'], $values['copy_from'], $values['social_icons'], $values['event_date'], $values['hidden-tags'], $values['block_direct_access'],
|
$values['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
|
$values['priority'], $values['password'], $values['pixieset'], $values['id_author'], $params
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ class Settings
|
|||||||
\admin\factory\Settings::settings_update( 'lazy_loading', $values['lazy_loading'] == 'on' ? 1 : 0 );
|
\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( '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( '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.' );
|
\S::alert( 'Ustawienia zostały zapisane.' );
|
||||||
|
|
||||||
|
|||||||
@@ -238,7 +238,7 @@ class Articles
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static function article_save(
|
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, $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,
|
$meta_keywords, $layout_id, $pages, $noindex, $repeat_entry, $copy_from, $social_icons, $event_date, $tags, $block_direct_access, $priority,
|
||||||
$password, $pixieset, $id_author, $params )
|
$password, $pixieset, $id_author, $params )
|
||||||
{
|
{
|
||||||
@@ -251,6 +251,7 @@ class Articles
|
|||||||
{
|
{
|
||||||
$mdb -> insert( 'pp_articles', [
|
$mdb -> insert( 'pp_articles', [
|
||||||
'show_title' => $show_title == 'on' ? 1 : 0,
|
'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_add' => $show_date_add == 'on' ? 1 : 0,
|
||||||
'show_date_modify' => $show_date_modify == '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_add' => $date_add ? $date_add : date( 'Y-m-d H:i:s' ),
|
||||||
@@ -435,6 +436,7 @@ class Articles
|
|||||||
{
|
{
|
||||||
$mdb -> update( 'pp_articles', [
|
$mdb -> update( 'pp_articles', [
|
||||||
'show_title' => $show_title == 'on' ? 1 : 0,
|
'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_add' => $show_date_add == 'on' ? 1 : 0,
|
||||||
'show_date_modify' => $show_date_modify == 'on' ? 1 : 0,
|
'show_date_modify' => $show_date_modify == 'on' ? 1 : 0,
|
||||||
'date_modify' => date( 'Y-m-d H:i:s' ),
|
'date_modify' => date( 'Y-m-d H:i:s' ),
|
||||||
|
|||||||
@@ -3,6 +3,30 @@ class S
|
|||||||
{
|
{
|
||||||
static public function generate_webp_image($file, $compression_quality = 85)
|
static public function generate_webp_image($file, $compression_quality = 85)
|
||||||
{
|
{
|
||||||
|
if ( strpos( $file, 'thumb/' ) !== false )
|
||||||
|
{
|
||||||
|
$file_tmp = explode( '/', $file );
|
||||||
|
|
||||||
|
$width = $file_tmp[1];
|
||||||
|
if ( empty( $width ) and $width !== '0' )
|
||||||
|
$width = 500;
|
||||||
|
|
||||||
|
$height = $file_tmp[2];
|
||||||
|
if ( empty( $height ) and $height !== '0' )
|
||||||
|
$height = 500;
|
||||||
|
|
||||||
|
for ( $i = 0; $i <= 2; $i++ )
|
||||||
|
unset( $file_tmp[$i] );
|
||||||
|
|
||||||
|
$img_src = implode( '/', $file_tmp );
|
||||||
|
|
||||||
|
$crop_w = $_GET['c_w'];
|
||||||
|
$crop_h = $_GET['c_h'];
|
||||||
|
|
||||||
|
$img_md5 = md5( $img_src . $height . $width . $crop_h . $crop_w );
|
||||||
|
$file = 'thumbs/' . $img_md5[0] . '/' . $img_md5[1] . '/' . $img_md5[2] . '/' . $img_md5;
|
||||||
|
}
|
||||||
|
|
||||||
if (!file_exists($file))
|
if (!file_exists($file))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -10,25 +34,24 @@ class S
|
|||||||
if (file_exists($output_file))
|
if (file_exists($output_file))
|
||||||
return $output_file;
|
return $output_file;
|
||||||
|
|
||||||
$file_type = strtolower(pathinfo($file, PATHINFO_EXTENSION));
|
$file_type = mime_content_type( $file );
|
||||||
|
|
||||||
if (function_exists('imagewebp'))
|
if (function_exists('imagewebp'))
|
||||||
{
|
{
|
||||||
switch ($file_type)
|
switch ($file_type)
|
||||||
{
|
{
|
||||||
case 'jpeg':
|
case 'image/jpeg':
|
||||||
case 'jpg':
|
|
||||||
$image = imagecreatefromjpeg($file);
|
$image = imagecreatefromjpeg($file);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'png':
|
case 'image/png':
|
||||||
$image = imagecreatefrompng($file);
|
$image = imagecreatefrompng($file);
|
||||||
imagepalettetotruecolor($image);
|
imagepalettetotruecolor($image);
|
||||||
imagealphablending($image, true);
|
imagealphablending($image, true);
|
||||||
imagesavealpha($image, true);
|
imagesavealpha($image, true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'gif':
|
case 'image/gif':
|
||||||
$image = imagecreatefromgif($file);
|
$image = imagecreatefromgif($file);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -742,7 +765,7 @@ $site_map[$domain['domain']] .= '<urlset xmlns="http://www.sitemaps.org/schemas/
|
|||||||
$seo = $language_link . \S::seo($row2['seo_link']);
|
$seo = $language_link . \S::seo($row2['seo_link']);
|
||||||
|
|
||||||
$robots .= 'Disallow: /' . $seo . '$' . PHP_EOL;
|
$robots .= 'Disallow: /' . $seo . '$' . PHP_EOL;
|
||||||
$robots .= 'Disallow: /' . $seo . '-s-*' . PHP_EOL;
|
$robots .= 'Disallow: /' . $seo . '/s/*' . PHP_EOL;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -752,7 +775,7 @@ $site_map[$domain['domain']] .= '<urlset xmlns="http://www.sitemaps.org/schemas/
|
|||||||
$seo = $language_link . 's-' . $row2['page_id'] . '-' . \S::seo($row2['title']);
|
$seo = $language_link . 's-' . $row2['page_id'] . '-' . \S::seo($row2['title']);
|
||||||
|
|
||||||
$robots .= 'Disallow: /' . $seo . '$' . PHP_EOL;
|
$robots .= 'Disallow: /' . $seo . '$' . PHP_EOL;
|
||||||
$robots .= 'Disallow: /' . $seo . '-s-*$' . PHP_EOL;
|
$robots .= 'Disallow: /' . $seo . '/s/*$' . PHP_EOL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -761,32 +784,25 @@ $site_map[$domain['domain']] .= '<urlset xmlns="http://www.sitemaps.org/schemas/
|
|||||||
{
|
{
|
||||||
if ($row['start'] and $row2['start'])
|
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;
|
$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'])
|
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 . '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 . '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 . '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]';
|
$htaccess_data .= PHP_EOL . 'RewriteRule ^(.*)$ ' . $domain_prefix . '://' . $www . $url_tmp . '/' . $language_link . ' [R=301,L]';
|
||||||
}
|
}
|
||||||
else
|
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 . '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 . '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 . '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 . '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 . 'RewriteCond %{REQUEST_URI} "^/$"';
|
||||||
$htaccess_data .= PHP_EOL . 'RewriteRule ^$ index.php?a=page&id=' . $row2['page_id'] . '&lang=' . $row['id'] . ' [L]';
|
$htaccess_data .= PHP_EOL . 'RewriteRule ^$ index.php?a=page&id=' . $row2['page_id'] . '&lang=' . $row['id'] . ' [L]';
|
||||||
|
|
||||||
@@ -800,26 +816,9 @@ $site_map[$domain['domain']] .= '<urlset xmlns="http://www.sitemaps.org/schemas/
|
|||||||
else
|
else
|
||||||
$seo = $language_link . \S::seo($row2['seo_link']);
|
$seo = $language_link . \S::seo($row2['seo_link']);
|
||||||
|
|
||||||
$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'] . '&%{QUERY_STRING} [L]';
|
||||||
$htaccess_data .= PHP_EOL . 'RewriteCond %{QUERY_STRING} ^(.*)(?:^|&)(utm_source|gclid)=[^&]+(&.*)?';
|
$htaccess_data .= PHP_EOL . 'RewriteRule ^' . $seo . '/s/1(|/)$ ' . $seo . ' [R=301,L]';
|
||||||
$htaccess_data .= PHP_EOL . 'RewriteRule ^' . $seo . '$ index.php?a=page&id=' . $row2['page_id'] . '&lang=' . $row['id'] . '&%{QUERY_STRING} [L]';
|
$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 . '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
|
else
|
||||||
{
|
{
|
||||||
@@ -828,26 +827,9 @@ $site_map[$domain['domain']] .= '<urlset xmlns="http://www.sitemaps.org/schemas/
|
|||||||
else
|
else
|
||||||
$seo = $language_link . 's-' . $row2['page_id'] . '-' . \S::seo($row2['title']);
|
$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 . 'RewriteRule ^' . $seo . '(|/)$ index.php?a=page&id=' . $row2['page_id'] . '&lang=' . $row['id'] . '&%{QUERY_STRING} [L]';
|
||||||
$htaccess_data .= PHP_EOL . 'RewriteCond %{QUERY_STRING} ^(.*)(?:^|&)(utm_source|gclid)=[^&]+(&.*)?';
|
$htaccess_data .= PHP_EOL . 'RewriteRule ^' . $seo . '/s/1(|/)$ ' . $seo . ' [R=301,L]';
|
||||||
$htaccess_data .= PHP_EOL . 'RewriteRule ^' . $seo . '$ index.php?a=page&id=' . $row2['page_id'] . '&lang=' . $row['id'] . '&%{QUERY_STRING} [L]';
|
$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 . '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;
|
$htaccess_data .= PHP_EOL;
|
||||||
}
|
}
|
||||||
@@ -911,29 +893,11 @@ $site_map[$domain['domain']] .= '<urlset xmlns="http://www.sitemaps.org/schemas/
|
|||||||
{
|
{
|
||||||
if ($row2['seo_link'])
|
if ($row2['seo_link'])
|
||||||
{
|
{
|
||||||
$htaccess_data .= PHP_EOL . 'RewriteCond %{HTTP_HOST} ^' . $domain . '$ [NC]';
|
$htaccess_data .= PHP_EOL . 'RewriteRule ^' . $language_link . \S::seo($row2['seo_link']) . '(|/)$ index.php?article=' . $row2['article_id'] . '&lang=' . $row['id'] . '&%{QUERY_STRING} [L]';
|
||||||
$htaccess_data .= PHP_EOL . 'RewriteCond %{QUERY_STRING} ^(.*)(?:^|&)(utm_source|gclid)=[^&]+(&.*)?';
|
|
||||||
$htaccess_data .= PHP_EOL . 'RewriteRule ^' . $language_link . \S::seo($row2['seo_link']) . '$ index.php?article=' . $row2['article_id'] . '&lang=' . $row['id'] . '&%{QUERY_STRING} [L]';
|
|
||||||
|
|
||||||
$htaccess_data .= PHP_EOL . 'RewriteCond %{HTTP_HOST} ^' . $domain . '$ [NC]';
|
|
||||||
$htaccess_data .= PHP_EOL . 'RewriteCond %{QUERY_STRING} !=""';
|
|
||||||
$htaccess_data .= PHP_EOL . 'RewriteRule ^' . $language_link . \S::seo($row2['seo_link']) . ' %{REQUEST_URI}? [R=301,L]';
|
|
||||||
|
|
||||||
$htaccess_data .= PHP_EOL . 'RewriteCond %{HTTP_HOST} ^' . $domain . '$ [NC]';
|
|
||||||
$htaccess_data .= PHP_EOL . 'RewriteRule ^' . $language_link . \S::seo($row2['seo_link']) . '$ index.php?article=' . $row2['article_id'] . '&lang=' . $row['id'] . ' [L]';
|
|
||||||
}
|
}
|
||||||
else if ($row2['title'] != null)
|
else if ($row2['title'] != null)
|
||||||
{
|
{
|
||||||
$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'] . '&%{QUERY_STRING} [L]';
|
||||||
$htaccess_data .= PHP_EOL . 'RewriteCond %{QUERY_STRING} ^(.*)(?:^|&)(utm_source|gclid)=[^&]+(&.*)?';
|
|
||||||
$htaccess_data .= PHP_EOL . 'RewriteRule ^' . $language_link . 'a-' . $row2['article_id'] . '-' . \S::seo($row2['title']) . '$ index.php?article=' . $row2['article_id'] . '&lang=' . $row['id'] . '&%{QUERY_STRING} [L]';
|
|
||||||
|
|
||||||
$htaccess_data .= PHP_EOL . 'RewriteCond %{HTTP_HOST} ^' . $domain . '$ [NC]';
|
|
||||||
$htaccess_data .= PHP_EOL . 'RewriteCond %{QUERY_STRING} !=""';
|
|
||||||
$htaccess_data .= PHP_EOL . 'RewriteRule ^' . $language_link . 'a-' . $row2['article_id'] . '-' . \S::seo($row2['title']) . ' %{REQUEST_URI}? [R=301,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;
|
$htaccess_data .= PHP_EOL;
|
||||||
}
|
}
|
||||||
@@ -951,8 +915,8 @@ $site_map[$domain['domain']] .= '<urlset xmlns="http://www.sitemaps.org/schemas/
|
|||||||
if (is_array($results) and !empty($results)) foreach ($results as $row)
|
if (is_array($results) and !empty($results)) foreach ($results as $row)
|
||||||
{
|
{
|
||||||
$htaccess_data .= PHP_EOL . 'RewriteCond %{QUERY_STRING} !=""';
|
$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'] ) . '(|/) %{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 . 'RewriteRule ^tag/' . \S::seo( $row['name'] ) . '(|/)$ index.php?tag=' . $row['tag_id'] . ' [L]';
|
||||||
}
|
}
|
||||||
|
|
||||||
$results = $mdb->get('pp_settings', 'value', ['param' => 'htaccess']);
|
$results = $mdb->get('pp_settings', 'value', ['param' => 'htaccess']);
|
||||||
@@ -972,79 +936,92 @@ $site_map[$domain['domain']] .= '<urlset xmlns="http://www.sitemaps.org/schemas/
|
|||||||
$site_map[$domain['domain']] .= '</urlset>';
|
$site_map[$domain['domain']] .= '</urlset>';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
$site_map[$url] .= '
|
$site_map[$url] .= '</urlset>';
|
||||||
</urlset>';
|
|
||||||
|
|
||||||
if ( $settings['ssl'] )
|
if ( $settings['ssl'] )
|
||||||
{
|
{
|
||||||
if ( $settings['link_version'] )
|
if ( $settings['link_version'] )
|
||||||
{
|
{
|
||||||
$htaccess_data = str_replace(
|
$redirect = 'RewriteCond %{HTTP_HOST} !^www\.' . PHP_EOL
|
||||||
'{REDIRECT}',
|
|
||||||
'RewriteCond %{HTTP_HOST} !^www\.' . PHP_EOL
|
|
||||||
. 'RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=permanent]' . PHP_EOL
|
. 'RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=permanent]' . PHP_EOL
|
||||||
|
|
||||||
. 'RewriteCond %{SERVER_PORT} !=443' . PHP_EOL
|
. 'RewriteCond %{SERVER_PORT} !=443' . PHP_EOL
|
||||||
. 'RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=permanent]' . PHP_EOL
|
. 'RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=permanent]' . PHP_EOL;
|
||||||
|
|
||||||
. '## Remove trailing slash' . PHP_EOL
|
if ( !$settings['url_version'] )
|
||||||
|
$redirect .= '## Remove trailing slash' . PHP_EOL
|
||||||
. 'RewriteCond %{REQUEST_FILENAME} !-d [NC]' . PHP_EOL
|
. 'RewriteCond %{REQUEST_FILENAME} !-d [NC]' . PHP_EOL
|
||||||
. 'RewriteCond %{REQUEST_URI} !^/admin/(.*) [NC]' . PHP_EOL
|
. 'RewriteCond %{REQUEST_URI} !^/admin/(.*) [NC]' . PHP_EOL
|
||||||
. 'RewriteRule ^(.*)/$ https://%{HTTP_HOST}/$1 [L,R=301]',
|
. 'RewriteRule ^(.*)/$ https://%{HTTP_HOST}/$1 [L,R=301]';
|
||||||
$htaccess_data
|
else
|
||||||
);
|
$redirect .= '## Add trailing slash' . PHP_EOL
|
||||||
|
. 'RewriteCond %{REQUEST_URI} !(/$|\.)' . PHP_EOL
|
||||||
|
. 'RewriteCond %{REQUEST_URI} !^/admin/(.*) [NC]' . PHP_EOL
|
||||||
|
. 'RewriteRule (.*) %{REQUEST_URI}/ [R=301,L]';
|
||||||
|
|
||||||
|
$htaccess_data = str_replace( '{REDIRECT}', $redirect, $htaccess_data );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$htaccess_data = str_replace(
|
$redirect = 'RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]' . PHP_EOL
|
||||||
'{REDIRECT}',
|
|
||||||
'RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]' . PHP_EOL
|
|
||||||
. 'RewriteRule ^(.*)$ https://%1/$1 [R=301,L]' . PHP_EOL
|
. 'RewriteRule ^(.*)$ https://%1/$1 [R=301,L]' . PHP_EOL
|
||||||
. 'RewriteCond %{SERVER_PORT} !=443' . PHP_EOL
|
. 'RewriteCond %{SERVER_PORT} !=443' . PHP_EOL
|
||||||
. 'RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=permanent]' . PHP_EOL
|
. 'RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=permanent]' . PHP_EOL;
|
||||||
|
|
||||||
. '## Remove trailing slash' . PHP_EOL
|
if ( !$settings['url_version'] )
|
||||||
|
$redirect .= '## Remove trailing slash' . PHP_EOL
|
||||||
. 'RewriteCond %{REQUEST_FILENAME} !-d [NC]' . PHP_EOL
|
. 'RewriteCond %{REQUEST_FILENAME} !-d [NC]' . PHP_EOL
|
||||||
. 'RewriteCond %{REQUEST_URI} !^/admin/(.*) [NC]' . PHP_EOL
|
. 'RewriteCond %{REQUEST_URI} !^/admin/(.*) [NC]' . PHP_EOL
|
||||||
. 'RewriteRule ^(.*)/$ https://%{HTTP_HOST}/$1 [L,R=301]',
|
. 'RewriteRule ^(.*)/$ https://%{HTTP_HOST}/$1 [L,R=301]';
|
||||||
$htaccess_data
|
else
|
||||||
);
|
$redirect .= '## Add trailing slash' . PHP_EOL
|
||||||
|
. 'RewriteCond %{REQUEST_URI} !(/$|\.)' . PHP_EOL
|
||||||
|
. 'RewriteCond %{REQUEST_URI} !^/admin/(.*) [NC]' . PHP_EOL
|
||||||
|
. 'RewriteRule (.*) %{REQUEST_URI}/ [R=301,L]';
|
||||||
|
|
||||||
|
$htaccess_data = str_replace( '{REDIRECT}', $redirect, $htaccess_data );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ($settings['link_version'])
|
if ($settings['link_version'])
|
||||||
{
|
{
|
||||||
$htaccess_data = str_replace(
|
$redirect = 'RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC]' . PHP_EOL
|
||||||
'{REDIRECT}',
|
|
||||||
'RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC]' . PHP_EOL
|
|
||||||
. 'RewriteRule ^(.*)$ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=permanent]' . PHP_EOL
|
. 'RewriteRule ^(.*)$ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=permanent]' . PHP_EOL
|
||||||
|
|
||||||
. 'RewriteCond %{SERVER_PORT} =443' . PHP_EOL
|
. 'RewriteCond %{SERVER_PORT} =443' . PHP_EOL
|
||||||
. 'RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=permanent]' . PHP_EOL
|
. 'RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=permanent]' . PHP_EOL;
|
||||||
|
|
||||||
. '## Remove trailing slash' . PHP_EOL
|
if ( !$settings['url_version'] )
|
||||||
|
$redirect .= '## Remove trailing slash' . PHP_EOL
|
||||||
. 'RewriteCond %{REQUEST_FILENAME} !-d [NC]' . PHP_EOL
|
. 'RewriteCond %{REQUEST_FILENAME} !-d [NC]' . PHP_EOL
|
||||||
. 'RewriteCond %{REQUEST_URI} !^/admin/(.*) [NC]' . PHP_EOL
|
. 'RewriteCond %{REQUEST_URI} !^/admin/(.*) [NC]' . PHP_EOL
|
||||||
. 'RewriteRule ^(.*)/$ http://%{HTTP_HOST}/$1 [L,R=301]',
|
. 'RewriteRule ^(.*)/$ http://%{HTTP_HOST}/$1 [L,R=301]';
|
||||||
$htaccess_data
|
else
|
||||||
);
|
$redirect .= '## Add trailing slash' . PHP_EOL
|
||||||
|
. 'RewriteCond %{REQUEST_URI} !(/$|\.)' . PHP_EOL
|
||||||
|
. 'RewriteCond %{REQUEST_URI} !^/admin/(.*) [NC]' . PHP_EOL
|
||||||
|
. 'RewriteRule (.*) %{REQUEST_URI}/ [R=301,L]';
|
||||||
|
|
||||||
|
$htaccess_data = str_replace( '{REDIRECT}', $redirect, $htaccess_data );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$htaccess_data = str_replace(
|
$redirect = 'RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]' . PHP_EOL
|
||||||
'{REDIRECT}',
|
|
||||||
'RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]' . PHP_EOL
|
|
||||||
. 'RewriteRule ^(.*)$ http://%1/$1 [R=301,L]' . PHP_EOL
|
. 'RewriteRule ^(.*)$ http://%1/$1 [R=301,L]' . PHP_EOL
|
||||||
. 'RewriteCond %{SERVER_PORT} =443' . PHP_EOL
|
. 'RewriteCond %{SERVER_PORT} =443' . PHP_EOL
|
||||||
. 'RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=permanent]' . PHP_EOL
|
. 'RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=permanent]' . PHP_EOL;
|
||||||
|
|
||||||
. '## Remove trailing slash' . PHP_EOL
|
if ( !$settings['url_version'] )
|
||||||
|
$redirect .= '## Remove trailing slash' . PHP_EOL
|
||||||
. 'RewriteCond %{REQUEST_FILENAME} !-d [NC]' . PHP_EOL
|
. 'RewriteCond %{REQUEST_FILENAME} !-d [NC]' . PHP_EOL
|
||||||
. 'RewriteCond %{REQUEST_URI} !^/admin/(.*) [NC]' . PHP_EOL
|
. 'RewriteCond %{REQUEST_URI} !^/admin/(.*) [NC]' . PHP_EOL
|
||||||
. 'RewriteRule ^(.*)/$ http://%{HTTP_HOST}/$1 [L,R=301]',
|
. 'RewriteRule ^(.*)/$ http://%{HTTP_HOST}/$1 [L,R=301]';
|
||||||
$htaccess_data
|
else
|
||||||
);
|
$redirect .= '## Add trailing slash' . PHP_EOL
|
||||||
|
. 'RewriteCond %{REQUEST_URI} !(/$|\.)' . PHP_EOL
|
||||||
|
. 'RewriteCond %{REQUEST_URI} !^/admin/(.*) [NC]' . PHP_EOL
|
||||||
|
. 'RewriteRule (.*) %{REQUEST_URI}/ [R=301,L]';
|
||||||
|
|
||||||
|
$htaccess_data = str_replace( '{REDIRECT}', $redirect, $htaccess_data );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1121,7 +1098,23 @@ fclose($fp);
|
|||||||
|
|
||||||
public static function seo( $val, $delete_rhombs = false )
|
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',
|
$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(130) => 'A', chr(195) . chr(131) => 'A',
|
||||||
chr(195) . chr(132) => 'A', chr(195) . chr(133) => 'A',
|
chr(195) . chr(132) => 'A', chr(195) . chr(133) => 'A',
|
||||||
chr(195) . chr(135) => 'C', chr(195) . chr(136) => 'E',
|
chr(195) . chr(135) => 'C', chr(195) . chr(136) => 'E',
|
||||||
@@ -1268,12 +1261,34 @@ $array_rep1 = array('*', '_', ' ', '+', '"', "'", '?', '-', ',', '!', '~', '<',
|
|||||||
|
|
||||||
public static function is_empty_dir($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();
|
return (($files = @scandir($dir)) && count($files) <= 2);
|
||||||
$mail->SMTPAuth = true;
|
}
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
$username = trim((string)$settings['email_login']);
|
||||||
|
$password = trim((string)$settings['email_password']);
|
||||||
|
$use_auth = ($username !== '' || $password !== '');
|
||||||
|
|
||||||
|
$build_mailer = function ($smtp_auth) use ($settings, $email, $subject, $text, $replay, $file, $username, $password)
|
||||||
|
{
|
||||||
|
$mail = new PHPMailer();
|
||||||
|
$mail->IsSMTP();
|
||||||
|
$mail->SMTPAuth = $smtp_auth ? true : false;
|
||||||
$mail->Host = $settings['email_host'];
|
$mail->Host = $settings['email_host'];
|
||||||
$mail->Port = $settings['email_port'];
|
$mail->Port = $settings['email_port'];
|
||||||
$mail->Username = $settings['email_login'];
|
$mail->Username = $username;
|
||||||
$mail->Password = $settings['email_password'];
|
$mail->Password = $password;
|
||||||
$mail->CharSet = "UTF-8";
|
$mail->CharSet = "UTF-8";
|
||||||
$mail->SMTPOptions = array(
|
$mail->SMTPOptions = array(
|
||||||
'ssl' => array(
|
'ssl' => array(
|
||||||
@@ -1311,7 +1326,22 @@ $array_rep1 = array('*', '_', ' ', '+', '"', "'", '?', '-', ',', '!', '~', '<',
|
|||||||
$mail->AddAttachment($file);
|
$mail->AddAttachment($file);
|
||||||
}
|
}
|
||||||
$mail->IsHTML(true);
|
$mail->IsHTML(true);
|
||||||
return $mail->Send();
|
|
||||||
|
return $mail;
|
||||||
|
};
|
||||||
|
|
||||||
|
$mail = $build_mailer($use_auth);
|
||||||
|
if ($mail->Send())
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if ($use_auth)
|
||||||
|
{
|
||||||
|
$mail = $build_mailer(false);
|
||||||
|
if ($mail->Send())
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,87 @@
|
|||||||
namespace front\factory;
|
namespace front\factory;
|
||||||
class Articles
|
class Articles
|
||||||
{
|
{
|
||||||
public static function pixieset_save_favorite_images( $hash ) {
|
static public function generateTableOfContents($content) {
|
||||||
|
$result = '';
|
||||||
|
$currentLevel = [];
|
||||||
|
|
||||||
|
preg_match_all('/<(h[1-6])([^>]*)>(.*?)<\/\1>/', $content, $matches, PREG_SET_ORDER);
|
||||||
|
|
||||||
|
$firstLevel = true;
|
||||||
|
|
||||||
|
foreach ($matches as $match) {
|
||||||
|
$level = intval(substr($match[1], 1));
|
||||||
|
|
||||||
|
while ($level < count($currentLevel)) {
|
||||||
|
$result .= '</li></ol>';
|
||||||
|
array_pop($currentLevel);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($level > count($currentLevel)) {
|
||||||
|
while ($level > count($currentLevel)) {
|
||||||
|
if (count($currentLevel) > 0 || $firstLevel) {
|
||||||
|
$result .= '<ol>';
|
||||||
|
$firstLevel = false;
|
||||||
|
}
|
||||||
|
array_push($currentLevel, 0);
|
||||||
|
}
|
||||||
|
$result .= '<li>';
|
||||||
|
} else {
|
||||||
|
$result .= '</li><li>';
|
||||||
|
}
|
||||||
|
|
||||||
|
$currentLevel[count($currentLevel) - 1]++;
|
||||||
|
|
||||||
|
preg_match('/\sid="([^"]*)"/', $match[2], $idMatches);
|
||||||
|
$id = isset($idMatches[1]) ? $idMatches[1] : '';
|
||||||
|
|
||||||
|
$result .= sprintf(
|
||||||
|
'<a href="#%s">%s</a>',
|
||||||
|
urlencode(strtolower($id)),
|
||||||
|
$match[3]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
while (!empty($currentLevel)) {
|
||||||
|
$result .= '</li></ol>';
|
||||||
|
array_pop($currentLevel);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (substr($result, 0, 8) === '<ol><ol>') {
|
||||||
|
return substr($result, 4, -5);
|
||||||
|
} else {
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// funkcja wywoływana dla każdego dopasowania do wyrażenia regularnego
|
||||||
|
static public function processHeaders( $matches )
|
||||||
|
{
|
||||||
|
$level = $matches[1];
|
||||||
|
$attrs = $matches[2];
|
||||||
|
$content = $matches[3];
|
||||||
|
$id_attr = 'id=';
|
||||||
|
$id_attr_pos = strpos($attrs, $id_attr);
|
||||||
|
if ($id_attr_pos === false) { // jeśli nie ma atrybutu id
|
||||||
|
$id = \S::seo( $content );
|
||||||
|
$attrs .= sprintf(' id="%s"', $id);
|
||||||
|
}
|
||||||
|
|
||||||
|
$html = sprintf( '<h%d%s>%s</h%d>', $level, $attrs, $content, $level );
|
||||||
|
return $html;
|
||||||
|
}
|
||||||
|
|
||||||
|
static public function generateHeadersIds( $text )
|
||||||
|
{
|
||||||
|
$pattern = '/<h([1-6])(.*?)>(.*?)<\/h\1>/si';
|
||||||
|
|
||||||
|
$text = preg_replace_callback( $pattern, array(__CLASS__, 'processHeaders'), $text );
|
||||||
|
|
||||||
|
return $text;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function pixieset_save_favorite_images( $hash )
|
||||||
|
{
|
||||||
global $mdb, $settings;
|
global $mdb, $settings;
|
||||||
|
|
||||||
\S::delete_dir( 'temp/' );
|
\S::delete_dir( 'temp/' );
|
||||||
@@ -149,6 +229,12 @@ class 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 ( 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 = new \DOMDocument();
|
||||||
|
|||||||
@@ -3,22 +3,22 @@ namespace front\factory;
|
|||||||
|
|
||||||
class Menu
|
class Menu
|
||||||
{
|
{
|
||||||
public static function submenu_details( $page_id )
|
public static function submenu_details( $page_id, $lang_id )
|
||||||
{
|
{
|
||||||
return self::subpages( $page_id );
|
return self::subpages( $page_id, $lang_id );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function subpages( $page_id )
|
static public function subpages( $page_id, $lang_id )
|
||||||
{
|
{
|
||||||
global $mdb;
|
global $mdb;
|
||||||
|
|
||||||
if ( !$pages = \Cache::fetch( "subpages:$page_id" ) )
|
if ( !$pages = \Cache::fetch( "subpages:$page_id:$lang_id" ) )
|
||||||
{
|
{
|
||||||
$results = $mdb -> select( 'pp_pages', [ 'id' ], [ 'AND' => [ 'status' => 1, 'parent_id' => $page_id ], 'ORDER' => [ 'o' => 'ASC' ] ] );
|
$results = $mdb -> select( 'pp_pages', [ 'id' ], [ 'AND' => [ 'status' => 1, 'parent_id' => $page_id ], 'ORDER' => [ 'o' => 'ASC' ] ] );
|
||||||
if ( is_array( $results ) ) foreach ( $results as $row )
|
if ( is_array( $results ) ) foreach ( $results as $row )
|
||||||
{
|
{
|
||||||
$page = \front\factory\Pages::page_details( $row['id'] );
|
$page = \front\factory\Pages::page_details( $row['id'] );
|
||||||
$page['pages'] = self::subpages( $row['id'] );
|
$page['pages'] = self::subpages( $row['id'], $lang_id );
|
||||||
|
|
||||||
$pages[] = $page;
|
$pages[] = $page;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -123,9 +123,10 @@ class Articles
|
|||||||
$out .= \front\view\Articles::password_view( [ 'article' => $article ] );
|
$out .= \front\view\Articles::password_view( [ 'article' => $article ] );
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$tpl = new \Tpl;
|
$out .= \Tpl::view( 'articles/article-full', [
|
||||||
$tpl -> article = $article_details;
|
'article' => $article_details,
|
||||||
$out .= $tpl -> render( 'articles/article-full' );
|
'table_of_contents' => \front\factory\Articles::generateTableOfContents( $article_details['language']['text'] )
|
||||||
|
] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ class Site
|
|||||||
{
|
{
|
||||||
$submenu_tmp = explode( ':', $submenu_tmp );
|
$submenu_tmp = explode( ':', $submenu_tmp );
|
||||||
$html = str_replace( '[SUBMENU:' . $submenu_tmp[1] . ']', \front\view\Menu::submenu(
|
$html = str_replace( '[SUBMENU:' . $submenu_tmp[1] . ']', \front\view\Menu::submenu(
|
||||||
\front\factory\Menu::submenu_details( $submenu_tmp[1] ), $page['id'], $submenu_tmp[1]
|
\front\factory\Menu::submenu_details( $submenu_tmp[1], $lang_id ), $page['id'], $submenu_tmp[1]
|
||||||
), $html );
|
), $html );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user