Files
inwestprofil.fr/ajax.php
Jacek Pyziak 86c704fd31 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.
2026-03-05 22:38:16 +01:00

213 lines
5.7 KiB
PHP

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