first commit
This commit is contained in:
76
autoload/front/controls/class.Articles.php
Normal file
76
autoload/front/controls/class.Articles.php
Normal file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
namespace front\controls;
|
||||
class Articles
|
||||
{
|
||||
public static function pixieset_save_favorite_images( $hash )
|
||||
{
|
||||
return \front\factory\Articles::pixieset_save_favorite_images( $hash );
|
||||
}
|
||||
|
||||
public static function pixieset_image_favorite( $image_id, $hash )
|
||||
{
|
||||
return \front\factory\Articles::pixieset_image_favorite( $image_id, $hash );
|
||||
}
|
||||
|
||||
public static function images_download( $hash )
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
$results = $mdb -> query( 'SELECT * FROM ('
|
||||
. 'SELECT id, MD5( CONCAT( id, date_add ) ) AS hash FROM pp_articles ) AS q1'
|
||||
. ' WHERE hash = \'' . $hash . '\'' ) -> fetchAll( \PDO::FETCH_ASSOC );
|
||||
if ( is_array( $results ) and count( $results ) ) foreach ( $results as $row )
|
||||
{
|
||||
$zip = new \ZipArchive;
|
||||
$tmp_file = 'temp/' . $hash . '.zip';
|
||||
|
||||
if ( file_exists( $tmp_file ) )
|
||||
return $tmp_file;
|
||||
|
||||
if ( $zip -> open( $tmp_file, \ZipArchive::CREATE ) )
|
||||
{
|
||||
$results2 = $mdb -> select( 'pp_articles_images', 'src', [ 'article_id' => $row['id'] ] );
|
||||
if ( is_array( $results2 ) and count( $results2 ) ) foreach ( $results2 as $row2 )
|
||||
{
|
||||
$file = substr( $row2, 1, strlen( $row2 ) );
|
||||
$zip -> addFile( $file, basename( $file ) );
|
||||
}
|
||||
|
||||
$zip -> close();
|
||||
|
||||
return $tmp_file;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function image()
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
$results = $mdb -> query( 'SELECT * FROM ('
|
||||
. 'SELECT id, src, MD5( CONCAT( id, src ) ) AS hash FROM pp_articles_images ) AS q1'
|
||||
. ' WHERE hash = \'' . \S::get( 'hash' ) . '\'' ) -> fetchAll( \PDO::FETCH_ASSOC );
|
||||
if ( is_array( $results ) and count( $results ) )
|
||||
{
|
||||
$file = substr( $results[0]['src'], 1, strlen( $results[0]['src'] ) );
|
||||
|
||||
header('Content-Description: File Transfer');
|
||||
header('Content-Type: application/octet-stream');
|
||||
header('Content-Disposition: attachment; filename="' . basename( $file ) . '"');
|
||||
header('Expires: 0');
|
||||
header('Cache-Control: must-revalidate');
|
||||
header('Pragma: public');
|
||||
header('Content-Length: ' . filesize( $file ) );
|
||||
flush();
|
||||
readfile($file);
|
||||
exit;
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function article_unlock( $password, $article_id )
|
||||
{
|
||||
if ( $password == \front\factory\Articles::article_password( $article_id ) )
|
||||
\S::set_session( 'article-' . $article_id . '-' . $password, true );
|
||||
}
|
||||
}
|
||||
63
autoload/front/controls/class.AuditSEO.php
Normal file
63
autoload/front/controls/class.AuditSEO.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
namespace front\controls;
|
||||
class AuditSEO
|
||||
{
|
||||
public static function semstorm()
|
||||
{
|
||||
echo json_encode( \front\factory\AuditSEO::semstorm( \S::get( 'url' ) ) );
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function data08()
|
||||
{
|
||||
echo json_encode( \front\factory\AuditSEO::data08( \S::get( 'url' ) ) );
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function data07()
|
||||
{
|
||||
echo json_encode( \front\factory\AuditSEO::data07( \S::get( 'url' ) ) );
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function data06()
|
||||
{
|
||||
echo json_encode( \front\factory\AuditSEO::data06( \S::get( 'url' ) ) );
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function data05()
|
||||
{
|
||||
echo json_encode( \front\factory\AuditSEO::data05( \S::get( 'url' ) ) );
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function data04()
|
||||
{
|
||||
echo json_encode( \front\factory\AuditSEO::data04( \S::get( 'url' ) ) );
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function data03()
|
||||
{
|
||||
echo json_encode( \front\factory\AuditSEO::data03( \S::get( 'url' ) ) );
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function data02()
|
||||
{
|
||||
echo json_encode( \front\factory\AuditSEO::data02( \S::get( 'url' ) ) );
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function data01()
|
||||
{
|
||||
echo json_encode( \front\factory\AuditSEO::data01( \S::get( 'url' ) ) );
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function main_view()
|
||||
{
|
||||
return \Tpl::view( 'audit-seo/main-view' );
|
||||
}
|
||||
}
|
||||
38
autoload/front/controls/class.Newsletter.php
Normal file
38
autoload/front/controls/class.Newsletter.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
namespace front\controls;
|
||||
|
||||
class Newsletter
|
||||
{
|
||||
public static function signin()
|
||||
{
|
||||
$result = [ 'status' => 'bad' ];
|
||||
|
||||
if ( \front\factory\Newsletter::newsletter_signin( \S::get( 'email' ) ) )
|
||||
$result = [ 'status' => 'ok' ];
|
||||
|
||||
echo json_encode( $result );
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function confirm()
|
||||
{
|
||||
global $lang;
|
||||
|
||||
if ( \front\factory\Newsletter::newsletter_confirm( \S::get( 'hash' ) ) )
|
||||
\S::alert( $lang['email-zostal-dodany-do-listy-newsletter'] );
|
||||
|
||||
header( 'Location: /' );
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function unsubscribe()
|
||||
{
|
||||
global $lang;
|
||||
|
||||
if ( \front\factory\Newsletter::newsletter_unsubscribe( \S::get( 'hash' ) ) )
|
||||
\S::alert( $lang['email-zostal-usuniety-z-listy-newsletter'] );
|
||||
|
||||
header( 'Location: /' );
|
||||
exit;
|
||||
}
|
||||
}
|
||||
122
autoload/front/controls/class.Site.php
Normal file
122
autoload/front/controls/class.Site.php
Normal file
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
namespace front\controls;
|
||||
|
||||
class Site
|
||||
{
|
||||
public static function route()
|
||||
{
|
||||
global $page, $lang_id;
|
||||
|
||||
if ( \S::get( 'search' ) )
|
||||
{
|
||||
if ( $_POST['search_txt'] )
|
||||
{
|
||||
\S::set_session( 'search_txt', \S::get( 'search_txt' ) );
|
||||
header( "Location: " . $_SERVER['REQUEST_URI'] );
|
||||
exit;
|
||||
}
|
||||
return \front\view\Search::search_results(
|
||||
\front\factory\Search::search_results( \S::get_session( 'search_txt' ), $lang_id )
|
||||
);
|
||||
}
|
||||
|
||||
if ( \S::get( 'tag' ) )
|
||||
return \front\view\Articles::articles_list(
|
||||
\front\factory\Articles::articles_by_tags( \S::get( 'tag' ), $lang_id )
|
||||
);
|
||||
|
||||
if ( \S::get( 'article' ) )
|
||||
{
|
||||
$article = new \Article( \S::get( 'article' ), $lang_id );
|
||||
if ( !\S::get_session( 'article-view-' . $article -> id ) )
|
||||
{
|
||||
$article -> updateView();
|
||||
\S::set_session( 'article-view-' . $article -> id, true );
|
||||
}
|
||||
|
||||
if ( $article['password'] and !\S::get_session( 'article-' . $article['id'] . '-' . $article['password'] ) )
|
||||
return \front\view\Articles::password_view( [ 'article' => $article ] );
|
||||
else
|
||||
return \front\view\Articles::article( [ 'article' => $article ] );
|
||||
}
|
||||
|
||||
if ( $page['page_type'] !== null )
|
||||
{
|
||||
switch ( $page['page_type'] )
|
||||
{
|
||||
/* pełne artykuły */
|
||||
case 0:
|
||||
return \front\view\Articles::full_articles_list( $page, $lang_id, \S::get( 'bs' ) );
|
||||
break;
|
||||
|
||||
/* wprowadzenia */
|
||||
case 1:
|
||||
return \front\view\Articles::entry_articles_list( $page, $lang_id, \S::get( 'bs' ) );
|
||||
break;
|
||||
|
||||
/* miniaturki */
|
||||
case 2:
|
||||
return \front\view\Articles::miniature_articles_list( $page, $lang_id, \S::get( 'bs' ) );
|
||||
break;
|
||||
|
||||
/* strona kontaktu */
|
||||
case 4:
|
||||
$out = \front\view\Articles::full_articles_list( $page, $lang_id, \S::get( 'bs' ) );
|
||||
$out .= \front\view\Site::contact();
|
||||
return $out;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !\S::get( 'module' ) || !\S::get( 'action' ) )
|
||||
return false;
|
||||
|
||||
$class = '\front\controls\\' . ucfirst( \S::get( 'module' ) );
|
||||
$action = \S::get( 'action' );
|
||||
|
||||
if ( class_exists( $class ) and method_exists( new $class, $action ) )
|
||||
return call_user_func_array( array( $class, $action ), array() );
|
||||
}
|
||||
|
||||
public static function check_url_params()
|
||||
{
|
||||
global $lang, $config;
|
||||
|
||||
$a = \S::get( 'a' );
|
||||
|
||||
switch ( $a )
|
||||
{
|
||||
case 'page':
|
||||
$page = \front\factory\Pages::page_details( \S::get( 'id' ) );
|
||||
\S::set_session( 'page', $page );
|
||||
break;
|
||||
|
||||
case 'change_language':
|
||||
\S::set_session( 'current-lang', \S::get( 'id' ) );
|
||||
header( 'Location: /' );
|
||||
exit;
|
||||
break;
|
||||
|
||||
case 'newsletter-sign':
|
||||
if ( \front\factory\Newsletter::newsletter_signin( \S::get( 'email' ) ) )
|
||||
\S::alert( 'Dziękujemy za zapisanie się do newslettera.' );
|
||||
header( 'Location: ' . $_SERVER['REQUEST_URI'] );
|
||||
exit;
|
||||
break;
|
||||
|
||||
case 'newsletter-signout':
|
||||
if ( \front\factory\Newsletter::newsletter_signout( \S::get( 'email' ) ) )
|
||||
\S::alert( 'Twój adres email został usunięty z naszej bazy.' );
|
||||
header( 'Location: ' . $_SERVER['REQUEST_URI'] );
|
||||
exit;
|
||||
break;
|
||||
}
|
||||
|
||||
if ( \S::get( 'lang' ) )
|
||||
\S::set_session( 'current-lang', \S::get( 'lang' ) );
|
||||
|
||||
if ( file_exists( 'modules/actions.php' ) )
|
||||
include 'modules/actions.php';
|
||||
}
|
||||
}
|
||||
?>
|
||||
479
autoload/front/factory/class.Articles.php
Normal file
479
autoload/front/factory/class.Articles.php
Normal file
@@ -0,0 +1,479 @@
|
||||
<?php
|
||||
|
||||
namespace front\factory;
|
||||
|
||||
class Articles
|
||||
{
|
||||
static public function generateTableOfContents($content)
|
||||
{
|
||||
$result = '';
|
||||
$prevLevel = 0;
|
||||
$stack = [];
|
||||
|
||||
// Tylko h1–h3
|
||||
preg_match_all('/<(h[1-3])([^>]*)>(.*?)<\/\1>/i', $content, $matches, PREG_SET_ORDER);
|
||||
|
||||
if (empty($matches))
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
foreach ($matches as $match)
|
||||
{
|
||||
$level = (int)substr($match[1], 1);
|
||||
$text = trim($match[3]);
|
||||
|
||||
// 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 .= '<ol>';
|
||||
$stack[] = $i + 1;
|
||||
}
|
||||
}
|
||||
elseif ($level < $prevLevel)
|
||||
{
|
||||
for ($i = $prevLevel; $i > $level; $i--)
|
||||
{
|
||||
$result .= '</li></ol>';
|
||||
array_pop($stack);
|
||||
}
|
||||
$result .= '</li>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$result .= '</li>';
|
||||
}
|
||||
|
||||
$result .= '<li><a href="#' . htmlspecialchars($id) . '">' . $text . '</a>';
|
||||
$prevLevel = $level;
|
||||
}
|
||||
|
||||
// Zamknij pozostałe listy
|
||||
while (!empty($stack))
|
||||
{
|
||||
$result .= '</li></ol>';
|
||||
array_pop($stack);
|
||||
}
|
||||
|
||||
return '<ol>' . $result . '</ol>';
|
||||
}
|
||||
|
||||
// funkcja wywoływana dla każdego dopasowania do wyrażenia regularnego
|
||||
static public function processHeaders($matches)
|
||||
{
|
||||
$level = $matches[1];
|
||||
$attrs = $matches[2];
|
||||
$content = $matches[3];
|
||||
$id_attr = 'id=';
|
||||
$id_attr_pos = strpos($attrs, $id_attr);
|
||||
if ($id_attr_pos === false)
|
||||
{ // jeśli nie ma atrybutu id
|
||||
$id = \S::seo($content);
|
||||
$attrs .= sprintf(' id="%s"', $id);
|
||||
}
|
||||
|
||||
$html = sprintf('<h%d%s>%s</h%d>', $level, $attrs, $content, $level);
|
||||
return $html;
|
||||
}
|
||||
|
||||
static public function generateHeadersIds($text)
|
||||
{
|
||||
$pattern = '/<h([1-6])(.*?)>(.*?)<\/h\1>/si';
|
||||
|
||||
$text = preg_replace_callback($pattern, array(__CLASS__, 'processHeaders'), $text);
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
public static function pixieset_save_favorite_images($hash)
|
||||
{
|
||||
global $mdb, $settings;
|
||||
|
||||
\S::delete_dir('temp/');
|
||||
|
||||
$rows = $mdb->select('pp_articles', ['id'], ['hash' => $hash]);
|
||||
if (is_array($rows)) foreach ($rows as $row)
|
||||
{
|
||||
$article = \front\factory\Articles::article_details($row['id'], 'pl');
|
||||
|
||||
$text = '<p>Witaj,<br />';
|
||||
$text .= 'Użytkownik zatwierdził listę wybranych przez siebie zdjęć.<br />';
|
||||
$text .= 'Poniżej znajdziesz nazwy wybranych zdjęć.</p>';
|
||||
$text .= '<ul>';
|
||||
if (is_array($article['images'])) foreach ($article['images'] as $image)
|
||||
if ($image['favorite'])
|
||||
$text .= '<li>' . basename($image['src']) . '</li>';
|
||||
$text .= '</ul>';
|
||||
|
||||
\S::send_email($settings['contact_email'], 'Powiadomienie ze strony: ' . $_SERVER['SERVER_NAME'], $text);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function pixieset_image_favorite($image_id, $hash)
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
$rows = $mdb->select('pp_articles', ['id'], ['hash' => $hash]);
|
||||
if (is_array($rows)) foreach ($rows as $row)
|
||||
{
|
||||
$status = $mdb->get('pp_articles_images', 'favorite', ['AND' => ['article_id' => $row['id'], 'id' => $image_id]]);
|
||||
$mdb->update('pp_articles_images', ['favorite' => !$status], ['AND' => ['article_id' => $row['id'], 'id' => $image_id]]);
|
||||
|
||||
\S::delete_dir('temp/');
|
||||
return !$status;
|
||||
}
|
||||
}
|
||||
|
||||
public static function article_password($article_id)
|
||||
{
|
||||
global $mdb;
|
||||
return $mdb->get('pp_articles', 'password', ['id' => $article_id]);
|
||||
}
|
||||
|
||||
public static function articles_by_tags($tag_id, $lang_id)
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
if (!$articles = \Cache::fetch("articles_by_tags:$tag_id:$lang_id"))
|
||||
{
|
||||
$results = $mdb->query('SELECT '
|
||||
. 'pa.id '
|
||||
. 'FROM '
|
||||
. 'pp_articles AS pa '
|
||||
. 'INNER JOIN pp_articles_tags AS pat ON pat.article_id = pa.id '
|
||||
. 'WHERE '
|
||||
. 'status = 1 '
|
||||
. 'AND '
|
||||
. 'tag_id = ' . (int)$tag_id)->fetchAll();
|
||||
if (is_array($results) and !empty($results)) foreach ($results as $row)
|
||||
$articles[] = \front\factory\Articles::article_details($row['id'], $lang_id);
|
||||
|
||||
\Cache::store("articles_by_tags:$tag_id:$lang_id", $articles);
|
||||
}
|
||||
|
||||
return $articles;
|
||||
}
|
||||
|
||||
public static function tag_details($tag_id)
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
if (!$tag = \Cache::fetch("tag_details:$tag_id"))
|
||||
{
|
||||
$tag = $mdb->get('pp_tags', '*', ['id' => (int)$tag_id]);
|
||||
|
||||
\Cache::store("tag_details:$tag_id", $tag);
|
||||
}
|
||||
return $tag;
|
||||
}
|
||||
|
||||
public static function tags()
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
if (!$tags = \Cache::fetch('tags'))
|
||||
{
|
||||
$tags = $mdb->query(
|
||||
'SELECT '
|
||||
. 'name, COUNT( tag_id ) AS c '
|
||||
. 'FROM '
|
||||
. 'pp_tags AS pt '
|
||||
. 'INNER JOIN pp_articles_tags ON pt.id = tag_id '
|
||||
. 'GROUP BY '
|
||||
. 'tag_id '
|
||||
. 'ORDER BY '
|
||||
. 'c DESC '
|
||||
. 'LIMIT 20'
|
||||
)->fetchAll();
|
||||
|
||||
\Cache::store('tags', $tags);
|
||||
}
|
||||
return $tags;
|
||||
}
|
||||
|
||||
public static function articles_by_date($month, $year, $lang_id)
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
if (!$articles = \Cache::fetch("articles_by_date:$month:$year:$lang_id"))
|
||||
{
|
||||
$results = $mdb->query('SELECT '
|
||||
. 'id '
|
||||
. 'FROM '
|
||||
. 'pp_articles '
|
||||
. 'WHERE '
|
||||
. 'status = 1 '
|
||||
. 'AND '
|
||||
. '( '
|
||||
. '( date_start BETWEEN \'' . date('Y-m-d', strtotime('01-' . $month . '-' . $year)) . '\' AND \'' . date('Y-m-t', strtotime('01-' . $month . '-' . $year)) . '\' ) '
|
||||
. 'OR '
|
||||
. '( date_end BETWEEN \'' . date('Y-m-d', strtotime('01-' . $month . '-' . $year)) . '\' AND \'' . date('Y-m-t', strtotime('01-' . $month . '-' . $year)) . '\' ) '
|
||||
. 'OR '
|
||||
. '( date_start <= \'' . date('Y-m-t', strtotime('01-' . $month . '-' . $year)) . '\' AND date_end >= \'' . date('Y-m-t', strtotime('01-' . $month . '-' . $year)) . '\' ) '
|
||||
. ')')->fetchAll();
|
||||
if (is_array($results) and !empty($results)) foreach ($results as $row)
|
||||
$articles[] = \front\factory\Articles::article_details($row['id'], $lang_id);
|
||||
|
||||
\Cache::store("articles_by_date:$month:$year:$lang_id", $articles);
|
||||
}
|
||||
|
||||
return $articles;
|
||||
}
|
||||
|
||||
public static function news($page_id, $limit = 6, $lang_id)
|
||||
{
|
||||
$sort = \front\factory\Pages::page_sort($page_id);
|
||||
|
||||
$articles_id = \front\factory\Articles::artciles_id((int)$page_id, $lang_id, $limit, $sort, 0);
|
||||
if (is_array($articles_id) and !empty($articles_id)) foreach ($articles_id as $article_id)
|
||||
$articles[] = \front\factory\Articles::article_details($article_id, $lang_id);
|
||||
|
||||
return $articles;
|
||||
}
|
||||
|
||||
public static function get_image($article, $skip_entry = false)
|
||||
{
|
||||
if ($article['language']['main_image'])
|
||||
{
|
||||
if (file_exists(substr($article['language']['main_image'], 1, strlen($article['language']['main_image']))))
|
||||
return $article['language']['main_image'];
|
||||
}
|
||||
|
||||
if (!$skip_entry)
|
||||
{
|
||||
$dom = new \DOMDocument();
|
||||
$dom->loadHTML(mb_convert_encoding($article['language']['entry'], 'HTML-ENTITIES', "UTF-8"));
|
||||
$images = $dom->getElementsByTagName('img');
|
||||
foreach ($images as $img)
|
||||
{
|
||||
$src = $img->getAttribute('src');
|
||||
if (file_exists(substr($src, 1, strlen($src))))
|
||||
return $src;
|
||||
}
|
||||
}
|
||||
|
||||
$dom = new \DOMDocument();
|
||||
$dom->loadHTML(mb_convert_encoding($article['language']['text'], 'HTML-ENTITIES', "UTF-8"));
|
||||
$images = $dom->getElementsByTagName('img');
|
||||
foreach ($images as $img)
|
||||
{
|
||||
$src = $img->getAttribute('src');
|
||||
if (file_exists(substr($src, 1, strlen($src))))
|
||||
return $src;
|
||||
}
|
||||
|
||||
if ($article['images'])
|
||||
return $article['images'][0]['src'];
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function article_noindex($article_id)
|
||||
{
|
||||
global $mdb, $lang;
|
||||
|
||||
if (!$noindex = \Cache::fetch("article_noindex:$article_id:" . $lang[0]))
|
||||
{
|
||||
$noindex = $mdb->get('pp_articles_langs', 'noindex', ['AND' => ['article_id' => (int)$article_id, 'lang_id' => $lang[0]]]);
|
||||
|
||||
\Cache::store("article_noindex:$article_id:" . $lang[0], $noindex);
|
||||
}
|
||||
return $noindex;
|
||||
}
|
||||
|
||||
public static function page_articles($page, $lang_id, $bs)
|
||||
{
|
||||
$count = \front\factory\Articles::page_articles_count($page['id'], $lang_id);
|
||||
$ls = ceil($count / $page['articles_limit']);
|
||||
|
||||
if ($bs < 1)
|
||||
$bs = 1;
|
||||
else if ($bs > $ls)
|
||||
$bs = $ls;
|
||||
|
||||
$from = $page['articles_limit'] * ($bs - 1);
|
||||
|
||||
if ($from < 0)
|
||||
$from = 0;
|
||||
|
||||
$results['articles'] = \front\factory\Articles::artciles_id((int)$page['id'], $lang_id, (int)$page['articles_limit'], $page['sort_type'], $from);
|
||||
$results['ls'] = $ls;
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
public static function article_details($article_id, $lang_id)
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
if (!$article = \Cache::fetch("article_details:$lang_id:$article_id"))
|
||||
{
|
||||
$article = $mdb->get('pp_articles', '*', ['id' => (int)$article_id]);
|
||||
|
||||
$results = $mdb->select('pp_articles_langs', '*', ['AND' => ['article_id' => (int)$article_id, 'lang_id' => $lang_id]]);
|
||||
if (is_array($results)) foreach ($results as $row)
|
||||
{
|
||||
if ($row['copy_from'])
|
||||
{
|
||||
$results2 = $mdb->select('pp_articles_langs', '*', ['AND' => ['article_id' => (int)$article_id, 'lang_id' => $row['copy_from']]]);
|
||||
if (is_array($results2)) foreach ($results2 as $row2)
|
||||
$article['language'] = $row2;
|
||||
}
|
||||
else
|
||||
$article['language'] = $row;
|
||||
|
||||
preg_match_all(\front\view\Site::container_pattern, $article['language']['entry'], $container_list);
|
||||
if (is_array($container_list[0])) foreach ($container_list[0] as $container_list_tmp)
|
||||
{
|
||||
$container_list_tmp = explode(':', $container_list_tmp);
|
||||
$article['language']['entry'] = str_replace('[KONTENER:' . $container_list_tmp[1] . ']', \front\view\Scontainers::scontainer($container_list_tmp[1]), $article['language']['entry']);
|
||||
}
|
||||
|
||||
preg_match_all(\front\view\Site::container_pattern, $article['language']['text'], $container_list);
|
||||
if (is_array($container_list[0])) foreach ($container_list[0] as $container_list_tmp)
|
||||
{
|
||||
$container_list_tmp = explode(':', $container_list_tmp);
|
||||
$article['language']['text'] = str_replace('[KONTENER:' . $container_list_tmp[1] . ']', \front\view\Scontainers::scontainer($container_list_tmp[1]), $article['language']['text']);
|
||||
}
|
||||
}
|
||||
|
||||
$article['images'] = $mdb->select('pp_articles_images', '*', ['article_id' => (int)$article_id, 'ORDER' => ['o' => 'ASC', 'id' => 'ASC'] ] );
|
||||
// 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'];
|
||||
else
|
||||
$params[$row['name']][$row['language_id']] = $row['value'];
|
||||
}
|
||||
$article['params'] = $params;
|
||||
|
||||
\Cache::store("article_details:$lang_id:$article_id", $article);
|
||||
}
|
||||
|
||||
return $article;
|
||||
}
|
||||
|
||||
public static function artciles_id($page_id, $lang_id, $articles_limit, $sort_type, $from)
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
switch ($sort_type)
|
||||
{
|
||||
case 0:
|
||||
$order = 'priority DESC, date_add ASC';
|
||||
break;
|
||||
case 1:
|
||||
$order = 'priority DESC, date_add DESC';
|
||||
break;
|
||||
case 2:
|
||||
$order = 'priority DESC, date_modify ASC';
|
||||
break;
|
||||
case 3:
|
||||
$order = 'priority DESC, date_modify DESC';
|
||||
break;
|
||||
case 4:
|
||||
$order = 'priority DESC, o ASC';
|
||||
break;
|
||||
case 5:
|
||||
$order = 'priority DESC, title ASC';
|
||||
break;
|
||||
case 6:
|
||||
$order = 'priority DESC, title DESC';
|
||||
break;
|
||||
default:
|
||||
$order = 'priority DESC, id ASC';
|
||||
break;
|
||||
}
|
||||
|
||||
if (!$output = \Cache::fetch("artciles_id:$page_id:$lang_id:$order:$from:$articles_limit"))
|
||||
{
|
||||
$results = $mdb->query('SELECT * FROM ( '
|
||||
. 'SELECT '
|
||||
. 'a.id, date_modify, date_add, o, priority, '
|
||||
. '( CASE '
|
||||
. 'WHEN copy_from IS NULL THEN title '
|
||||
. 'WHEN copy_from IS NOT NULL THEN ( '
|
||||
. 'SELECT '
|
||||
. 'title '
|
||||
. 'FROM '
|
||||
. 'pp_articles_langs '
|
||||
. 'WHERE '
|
||||
. 'lang_id = al.copy_from AND article_id = a.id '
|
||||
. ') '
|
||||
. 'END ) AS title '
|
||||
. 'FROM '
|
||||
. 'pp_articles_pages AS ap '
|
||||
. 'INNER JOIN pp_articles AS a ON a.id = ap.article_id '
|
||||
. 'INNER JOIN pp_articles_langs AS al ON al.article_id = ap.article_id '
|
||||
. 'WHERE '
|
||||
. 'status = 1 AND page_id = ' . (int)$page_id . ' AND lang_id = \'' . $lang_id . '\' '
|
||||
. ') AS q1 '
|
||||
. 'WHERE '
|
||||
. 'q1.title IS NOT NULL '
|
||||
. 'ORDER BY '
|
||||
. 'q1.' . $order . ' '
|
||||
. 'LIMIT '
|
||||
. (int)$from . ',' . (int)$articles_limit)->fetchAll();
|
||||
if (is_array($results) and !empty($results)) foreach ($results as $row)
|
||||
$output[] = $row['id'];
|
||||
|
||||
\Cache::store("artciles_id:$page_id:$lang_id:$order:$from:$articles_limit", $output);
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
public static function page_articles_count($page_id, $lang_id)
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
if (!$output = \Cache::fetch("page_articles_count:$page_id:$lang_id"))
|
||||
{
|
||||
$results = $mdb->query('SELECT COUNT(0) FROM ( '
|
||||
. 'SELECT '
|
||||
. 'a.id, '
|
||||
. '( CASE '
|
||||
. 'WHEN copy_from IS NULL THEN title '
|
||||
. 'WHEN copy_from IS NOT NULL THEN ( '
|
||||
. 'SELECT '
|
||||
. 'title '
|
||||
. 'FROM '
|
||||
. 'pp_articles_langs '
|
||||
. 'WHERE '
|
||||
. 'lang_id = al.copy_from AND article_id = a.id '
|
||||
. ') '
|
||||
. 'END ) AS title '
|
||||
. 'FROM '
|
||||
. 'pp_articles_pages AS ap '
|
||||
. 'INNER JOIN pp_articles AS a ON a.id = ap.article_id '
|
||||
. 'INNER JOIN pp_articles_langs AS al ON al.article_id = ap.article_id '
|
||||
. 'WHERE '
|
||||
. 'status = 1 AND page_id = ' . (int)$page_id . ' AND lang_id = \'' . $lang_id . '\' '
|
||||
. ') AS q1 '
|
||||
. 'WHERE '
|
||||
. 'q1.title IS NOT NULL')->fetchAll();
|
||||
$output = $results[0][0];
|
||||
\Cache::store("page_articles_count:$page_id:$lang_id", $output);
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
765
autoload/front/factory/class.AuditSEO.php
Normal file
765
autoload/front/factory/class.AuditSEO.php
Normal file
@@ -0,0 +1,765 @@
|
||||
<?php
|
||||
namespace front\factory;
|
||||
class AuditSEO
|
||||
{
|
||||
public static $good_img = '<img src="/templates/audit-seo/good.svg" class="status">';
|
||||
public static $bad_img = '<img src="/templates/audit-seo/bad.svg" class="status">';
|
||||
|
||||
public static function robots_allowed( $robots_txt, $useragent )
|
||||
{
|
||||
$agents = array( preg_quote( '*' ) );
|
||||
if ( $useragent) $agents[] = preg_quote( $useragent );
|
||||
$agents = implode( '|', $agents );
|
||||
|
||||
$robotstxt = @file( $robots_txt );
|
||||
if ( empty( $robotstxt ) )
|
||||
return true;
|
||||
|
||||
$rules = array();
|
||||
$ruleApplies = false;
|
||||
foreach ( $robotstxt as $line )
|
||||
{
|
||||
if ( !$line = trim( $line ) )
|
||||
continue;
|
||||
|
||||
if ( preg_match('/^\s*User-agent: (.*)/i', $line, $match ) )
|
||||
$ruleApplies = preg_match( "/($agents)/i", $match[1] );
|
||||
|
||||
if ( $ruleApplies && preg_match( '/^\s*Disallow:(.*)/i', $line, $regs ) )
|
||||
{
|
||||
if ( !$regs[1] )
|
||||
return true;
|
||||
|
||||
$rules[] = preg_quote( trim( $regs[1] ), '/' );
|
||||
}
|
||||
}
|
||||
|
||||
foreach ( $rules as $rule )
|
||||
{
|
||||
if ( preg_match( "/^$rule/", $parsed['path'] ) )
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function is_url_internal( $domain, $url )
|
||||
{
|
||||
$domain_host = parse_url( $domain, PHP_URL_HOST );
|
||||
$url_host = parse_url( $url, PHP_URL_HOST );
|
||||
|
||||
if ( $domain_host == $url_host or empty( $url_host ) )
|
||||
{
|
||||
if ( $url != '/' and $url != '#' and strpos( $url, 'mailto:' ) === false and $url != '' and strpos( $url, 'tel:' ) === false )
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function is_url_external( $domain, $url )
|
||||
{
|
||||
$domain_host = str_replace( 'www.', '', parse_url( $domain, PHP_URL_HOST ) );
|
||||
$url_host = str_replace( 'www.', '', parse_url( $url, PHP_URL_HOST ) );
|
||||
|
||||
if ( $domain_host != $url_host and !empty( $url_host ) and !empty( $domain_host ) )
|
||||
{
|
||||
if ( $url != '/' and $url != '#' and strpos( $url, 'mailto:' ) === false and $url != '' and strpos( $url, 'tel:' ) === false )
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function semstorm( $url )
|
||||
{
|
||||
if ( !$url )
|
||||
return false;
|
||||
|
||||
$data = [ 'domains' => [ $url ] ];
|
||||
$data_string = json_encode( $data );
|
||||
|
||||
$ch = curl_init();
|
||||
curl_setopt( $ch, CURLOPT_URL, 'http://api.semstorm.com/api-v3/explorer/explorer-keywords/position-distribution.json?services_token=ay_oMCvqro2DuTbG5EMayLUTYitOJC_Lf40gq2Rj_zE' );
|
||||
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
|
||||
curl_setopt( $ch, CURLOPT_VERBOSE, 1 );
|
||||
curl_setopt( $ch, CURLOPT_TIMEOUT, 60 );
|
||||
curl_setopt( $ch, CURLOPT_HEADER, false );
|
||||
curl_setopt( $ch, CURLOPT_POST, true );
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen( $data_string ) )
|
||||
);
|
||||
$response = curl_exec( $ch );
|
||||
curl_close ( $ch );
|
||||
|
||||
echo $response;
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function data08( $url )
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
$data08['top3']['txt'] = 0;
|
||||
$data08['top10']['txt'] = 0;
|
||||
$data08['top50']['txt'] = 0;
|
||||
$results = $mdb -> get( 'as_sites', [ 'semstorm' ], [ 'url' => $url ] );
|
||||
|
||||
if ( !$results['semstorm'] )
|
||||
{
|
||||
if ( strpos( $url, 'www.' ) === 0 )
|
||||
$url = str_replace( 'www.', '', $url );
|
||||
|
||||
$data = [ 'domains' => [ $url ] ];
|
||||
$data_string = json_encode( $data );
|
||||
|
||||
$ch = curl_init();
|
||||
curl_setopt( $ch, CURLOPT_URL, 'http://api.semstorm.com/api-v3/explorer/explorer-keywords/position-distribution.json?services_token=ay_oMCvqro2DuTbG5EMayLUTYitOJC_Lf40gq2Rj_zE' );
|
||||
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
|
||||
curl_setopt( $ch, CURLOPT_VERBOSE, 1 );
|
||||
curl_setopt( $ch, CURLOPT_TIMEOUT, 60 );
|
||||
curl_setopt( $ch, CURLOPT_HEADER, false );
|
||||
curl_setopt( $ch, CURLOPT_POST, true );
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string );
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen( $data_string ) )
|
||||
);
|
||||
$response = curl_exec( $ch );
|
||||
curl_close ( $ch );
|
||||
$mdb -> update( 'as_sites', [ 'semstorm' => $response ], [ 'url' => $url ] );
|
||||
|
||||
$results['semstorm'] = $response;
|
||||
}
|
||||
|
||||
$data_tmp = json_decode( $results['semstorm'], true );
|
||||
|
||||
foreach ( $data_tmp['results'][$url] as $key => $val )
|
||||
{
|
||||
if ( $key <= 3 )
|
||||
$data08['top3']['txt'] += $val;
|
||||
|
||||
if ( $key > 3 and $key <= 10 )
|
||||
$data08['top10']['txt'] += $val;
|
||||
|
||||
if ( $key > 10 )
|
||||
$data08['top50']['txt'] += $val;
|
||||
}
|
||||
|
||||
return $data08;
|
||||
}
|
||||
|
||||
public static function data07( $url )
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
$results = $mdb -> get( 'as_sites', [ 'html', 'effective_url' ], [ 'url' => $url ] );
|
||||
|
||||
$data07['audit_links_inside']['count'] = 0;
|
||||
$data07['audit_links_outside']['count'] = 0;
|
||||
|
||||
$dom = new \DOMDocument();
|
||||
@$dom -> loadHTML( $results['html'] );
|
||||
$links = @$dom -> getElementsByTagName( 'a' );
|
||||
|
||||
for ( $i = 0; $i < $links -> length; $i++ )
|
||||
{
|
||||
$link = $links -> item( $i );
|
||||
$url_tmp = $link -> getAttribute( 'href' );
|
||||
|
||||
if ( self::is_url_internal( $results['effective_url'], $url_tmp ) )
|
||||
{
|
||||
$data07['audit_links_inside']['count']++;
|
||||
$links_internal[] = $url_tmp;
|
||||
}
|
||||
|
||||
if ( self::is_url_external( $results['effective_url'], $url_tmp ) )
|
||||
{
|
||||
$data07['audit_links_outside']['count']++;
|
||||
$links_external[] = $url_tmp;
|
||||
}
|
||||
}
|
||||
$data07['audit_links_inside']['txt'] = implode( '<br>', $links_internal );
|
||||
$data07['audit_links_outside']['txt'] = implode( '<br>', $links_external );
|
||||
|
||||
return $data07;
|
||||
}
|
||||
|
||||
public static function data06( $url )
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
$results = $mdb -> get( 'as_sites', [ 'effective_url', 'html', 'flash', 'iframe', 'file_robots_txt', 'file_sitemap_xml', 'inline_css', 'doctype', 'html_language', 'w3c' ], [ 'url' => $url ] );
|
||||
|
||||
$data06['flash']['txt'] = $results['flash'] ? 'tak' : 'nie';
|
||||
$data06['iframe']['txt'] = $results['iframe'] ? 'tak' : 'nie';
|
||||
$data06['file_robots_txt']['txt'] = $results['file_robots_txt'] ? 'tak' : 'nie';
|
||||
$data06['file_sitemap_xml']['txt'] = $results['file_sitemap_xml'] ? 'tak' : 'nie';
|
||||
$data06['imgs_without_alt']['txt'] = implode( '<br/>', self::imgs_without_alt( $results['html'] ) );
|
||||
$data06['inline_css']['txt'] = $results['inline_css'] ? 'tak' : 'nie';
|
||||
$data06['doctype']['txt'] = $results['doctype'];
|
||||
$data06['html_language']['txt'] = $results['html_language'];
|
||||
|
||||
if ( !$results['w3c'] )
|
||||
{
|
||||
$ch = curl_init();
|
||||
curl_setopt( $ch, CURLOPT_URL, 'https://validator.w3.org/nu/?doc=' . urlencode( $results['effective_url'] ) . '%2F&out=json' );
|
||||
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
|
||||
curl_setopt( $ch, CURLOPT_VERBOSE, 1 );
|
||||
curl_setopt( $ch, CURLOPT_TIMEOUT, 60 );
|
||||
curl_setopt( $ch, CURLOPT_HEADER, true );
|
||||
curl_setopt( $ch, CURLOPT_CAINFO, 'cacert.pem' );
|
||||
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );
|
||||
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true );
|
||||
curl_setopt( $ch, CURLOPT_HEADER, false );
|
||||
curl_setopt( $ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.103 Safari/537.36' );
|
||||
$response = curl_exec( $ch );
|
||||
curl_close ( $ch );
|
||||
|
||||
$mdb -> update( 'as_sites', [ 'w3c' => $response ], [ 'url' => $url ] );
|
||||
|
||||
$w3c = json_decode( $response, true );
|
||||
}
|
||||
else
|
||||
{
|
||||
$w3c = json_decode( $results['w3c'], true );
|
||||
}
|
||||
|
||||
$data06['w3c_validator']['txt'] = 0;
|
||||
|
||||
foreach ( $w3c['messages'] as $message ) {
|
||||
if ( $message['type'] == 'error' )
|
||||
$data06['w3c_validator']['txt']++;
|
||||
}
|
||||
|
||||
return $data06;
|
||||
}
|
||||
|
||||
public static function data05( $url )
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
$results = $mdb -> get( 'as_sites', [
|
||||
'effective_url',
|
||||
'page_speed_insight_mobile'
|
||||
], [
|
||||
'url' => $url
|
||||
] );
|
||||
|
||||
if ( !$results['page_speed_insight_mobile'] )
|
||||
{
|
||||
$ch = curl_init();
|
||||
curl_setopt( $ch, CURLOPT_URL, 'https://www.googleapis.com/pagespeedonline/v5/runPagespeed?url=' . $results['effective_url'] . '&category=performance&strategy=mobile' );
|
||||
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
|
||||
curl_setopt( $ch, CURLOPT_VERBOSE, 1 );
|
||||
curl_setopt( $ch, CURLOPT_TIMEOUT, 60 );
|
||||
curl_setopt( $ch, CURLOPT_HEADER, true );
|
||||
curl_setopt( $ch, CURLOPT_CAINFO, 'cacert.pem' );
|
||||
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );
|
||||
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true );
|
||||
curl_setopt( $ch, CURLOPT_HEADER, false );
|
||||
curl_setopt( $ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.103 Safari/537.36' );
|
||||
$response = curl_exec( $ch );
|
||||
curl_close ( $ch );
|
||||
|
||||
$mdb -> update( 'as_sites', [ 'page_speed_insight_mobile' => $response ], [ 'url' => $url ] );
|
||||
|
||||
$page_speed_insight_mobile = json_decode( $response, true );
|
||||
}
|
||||
else
|
||||
{
|
||||
$page_speed_insight_mobile = json_decode( $results['page_speed_insight_mobile'], true );
|
||||
}
|
||||
|
||||
$data05['psid']['txt'] = ( $page_speed_insight_mobile['lighthouseResult']['categories']['performance']['score'] * 100 ) . '/100';
|
||||
$data05['psid']['score'] = $page_speed_insight_mobile['lighthouseResult']['categories']['performance']['score'] * 100;
|
||||
|
||||
return $data05;
|
||||
}
|
||||
|
||||
public static function data04( $url )
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
$results = $mdb -> get( 'as_sites', [
|
||||
'effective_url',
|
||||
'page_speed_insight_desktop'
|
||||
], [
|
||||
'url' => $url
|
||||
] );
|
||||
|
||||
if ( !$results['page_speed_insight_desktop'] )
|
||||
{
|
||||
$ch = curl_init();
|
||||
curl_setopt( $ch, CURLOPT_URL, 'https://www.googleapis.com/pagespeedonline/v5/runPagespeed?url=' . $results['effective_url'] . '&category=performance&strategy=desktop' );
|
||||
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
|
||||
curl_setopt( $ch, CURLOPT_VERBOSE, 1 );
|
||||
curl_setopt( $ch, CURLOPT_TIMEOUT, 60 );
|
||||
curl_setopt( $ch, CURLOPT_HEADER, true );
|
||||
curl_setopt( $ch, CURLOPT_CAINFO, 'cacert.pem' );
|
||||
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );
|
||||
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true );
|
||||
curl_setopt( $ch, CURLOPT_HEADER, false );
|
||||
curl_setopt( $ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.103 Safari/537.36' );
|
||||
$response = curl_exec( $ch );
|
||||
curl_close ( $ch );
|
||||
|
||||
$mdb -> update( 'as_sites', [ 'page_speed_insight_desktop' => $response ], [ 'url' => $url ] );
|
||||
|
||||
$page_speed_insight_desktop = json_decode( $response, true );
|
||||
}
|
||||
else
|
||||
{
|
||||
$page_speed_insight_desktop = json_decode( $results['page_speed_insight_desktop'], true );
|
||||
}
|
||||
|
||||
$data04['psid']['txt'] = ( $page_speed_insight_desktop['lighthouseResult']['categories']['performance']['score'] * 100 ) . '/100';
|
||||
$data04['psid']['score'] = $page_speed_insight_desktop['lighthouseResult']['categories']['performance']['score'] * 100;
|
||||
$data04['site_size']['txt'] = round( $page_speed_insight_desktop['lighthouseResult']['audits']['total-byte-weight']['numericValue'] / 1024 ) . ' KB';
|
||||
$data04['site_http']['txt'] = $page_speed_insight_desktop['lighthouseResult']['audits']['network-requests']['numericValue'];
|
||||
|
||||
return $data04;
|
||||
}
|
||||
|
||||
public static function data03( $url )
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
$results = $mdb -> get( 'as_sites', [ 'meta_title', 'meta_description', 'meta_keywords', 'code_length', 'text_length', 'words_count',
|
||||
'h1_count', 'h2_count', 'h3_count', 'h4_count', 'h5_count', 'h6_count'
|
||||
], [
|
||||
'url' => $url
|
||||
] );
|
||||
|
||||
$data03['meta_title']['txt'] = $results['meta_title'];
|
||||
$data03['meta_title']['signs'] = strlen( $results['meta_title'] );
|
||||
$data03['meta_description']['txt'] = $results['meta_description'];
|
||||
$data03['meta_description']['signs'] = strlen( $results['meta_description'] );
|
||||
$data03['meta_keywords']['txt'] = $results['meta_keywords'] != '' ? $results['meta_keywords'] : 'brak';
|
||||
$data03['code_to_text_ratio']['txt'] = round( ( $results['text_length'] / ( $results['text_length'] + $results['code_length'] ) * 100 ), 0 );
|
||||
$data03['words_count']['txt'] = $results['words_count'];
|
||||
$data03['headers']['h1_count']['txt'] = $results['h1_count'];
|
||||
$data03['headers']['h2_count']['txt'] = $results['h2_count'];
|
||||
$data03['headers']['h3_count']['txt'] = $results['h3_count'];
|
||||
$data03['headers']['h4_count']['txt'] = $results['h4_count'];
|
||||
$data03['headers']['h5_count']['txt'] = $results['h5_count'];
|
||||
$data03['headers']['h6_count']['txt'] = $results['h6_count'];
|
||||
|
||||
return $data03;
|
||||
}
|
||||
|
||||
public static function data02( $url )
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
$results = $mdb -> get( 'as_sites', [ 'meta_robots', 'robots_txt', 'redirect_www', 'https' ], [ 'url' => $url ] );
|
||||
|
||||
$data02['meta_robots']['txt'] = strpos( $results['meta_robots'], 'index' ) !== false ? 'tak' : 'nie';
|
||||
$data02['meta_robots']['img'] = strpos( $results['meta_robots'], 'index' ) !== false ? self::$good_img : self::$bad_img;
|
||||
|
||||
$robots_txt = self::robots_allowed( $data02['robots_txt'], 'GoogleBot' );
|
||||
$data02['robots_txt']['txt'] = $robots_txt ? 'tak' : 'nie';
|
||||
$data02['robots_txt']['img'] = $robots_txt ? self::$good_img : self::$bad_img;
|
||||
|
||||
$data02['redirect_www']['txt'] = $results['redirect_www'] ? 'tak' : 'nie';
|
||||
$data02['redirect_www']['img'] = $results['redirect_www'] ? self::$good_img : self::$bad_img;
|
||||
|
||||
$data02['https']['txt'] = $results['https'] ? 'tak' : 'nie';
|
||||
$data02['https']['img'] = $results['https'] ? self::$good_img : self::$bad_img;
|
||||
|
||||
return $data02;
|
||||
}
|
||||
|
||||
public static function data01( $url )
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
$data01 = $mdb -> get( 'as_sites', [
|
||||
'effective_url',
|
||||
'ip',
|
||||
'location',
|
||||
'favicon',
|
||||
'cms'
|
||||
], [
|
||||
'url' => $url
|
||||
] );
|
||||
|
||||
$url_tmp = parse_url( $data01['effective_url'] );
|
||||
|
||||
$location = json_decode( $data01['location'] );
|
||||
$data01['domain']['txt'] = $url_tmp['host'];
|
||||
$data01['location'] = $location -> country;
|
||||
$data01['favicon'] = $data01['favicon'] != null ? 'tak' : 'nie';
|
||||
$data01['cms'] = $data01['cms'] != null ? $data01['cms'] : 'nieznany';
|
||||
|
||||
return $data01;
|
||||
}
|
||||
|
||||
public static function imgs_without_alt( $html )
|
||||
{
|
||||
$dom = new \DOMDocument();
|
||||
@$dom -> loadHTML( $html );
|
||||
$images = $dom -> getElementsByTagName( 'img' );
|
||||
$cms = '';
|
||||
|
||||
for ( $i = 0; $i < $images -> length; $i++ )
|
||||
{
|
||||
$img = $images -> item( $i );
|
||||
if ( $img -> getAttribute( 'alt' ) == '' )
|
||||
$imgs_output[] = $img -> getAttribute( 'src' );
|
||||
}
|
||||
return $imgs_output;
|
||||
}
|
||||
|
||||
public static function cms( $html )
|
||||
{
|
||||
$dom = new \DOMDocument();
|
||||
@$dom -> loadHTML( $html );
|
||||
$metas = $dom -> getElementsByTagName( 'meta' );
|
||||
$cms = '';
|
||||
|
||||
for ( $i = 0; $i < $metas -> length; $i++ )
|
||||
{
|
||||
$meta = $metas -> item( $i );
|
||||
if ( $meta -> getAttribute( 'name' ) == 'generator' )
|
||||
$cms = $meta -> getAttribute( 'content' );
|
||||
}
|
||||
return $cms;
|
||||
}
|
||||
|
||||
public static function meta_title( $html )
|
||||
{
|
||||
$dom = new \DOMDocument();
|
||||
@$dom -> loadHTML( $html );
|
||||
$metas = $dom -> getElementsByTagName( 'title' );
|
||||
$meta_title = '';
|
||||
|
||||
$meta = $metas -> item( 0 );
|
||||
$meta_title = $meta -> textContent;
|
||||
|
||||
return $meta_title;
|
||||
}
|
||||
|
||||
public static function meta_description( $html )
|
||||
{
|
||||
$dom = new \DOMDocument();
|
||||
@$dom -> loadHTML( $html );
|
||||
$metas = $dom -> getElementsByTagName( 'meta' );
|
||||
$meta_description = '';
|
||||
|
||||
for ( $i = 0; $i < $metas -> length; $i++ )
|
||||
{
|
||||
$meta = $metas -> item( $i );
|
||||
if ( $meta -> getAttribute( 'name' ) == 'description' )
|
||||
$meta_description = $meta -> getAttribute( 'content' );
|
||||
}
|
||||
return $meta_description;
|
||||
}
|
||||
|
||||
public static function meta_keywords( $html )
|
||||
{
|
||||
$dom = new \DOMDocument();
|
||||
@$dom -> loadHTML( $html );
|
||||
$metas = $dom -> getElementsByTagName( 'meta' );
|
||||
$meta_keywords = '';
|
||||
|
||||
for ( $i = 0; $i < $metas -> length; $i++ )
|
||||
{
|
||||
$meta = $metas -> item( $i );
|
||||
if ( $meta -> getAttribute( 'name' ) == 'keywords' )
|
||||
$meta_keywords = $meta -> getAttribute( 'content' );
|
||||
}
|
||||
return $meta_keywords;
|
||||
}
|
||||
|
||||
public static function meta_robots( $html )
|
||||
{
|
||||
$dom = new \DOMDocument();
|
||||
@$dom -> loadHTML( $html );
|
||||
$metas = $dom -> getElementsByTagName( 'meta' );
|
||||
$meta_robots = '';
|
||||
|
||||
for ( $i = 0; $i < $metas -> length; $i++ )
|
||||
{
|
||||
$meta = $metas -> item( $i );
|
||||
if ( $meta -> getAttribute( 'name' ) == 'robots' || $meta -> getAttribute( 'name' ) == 'googlebot' )
|
||||
$meta_robots = $meta -> getAttribute( 'content' );
|
||||
}
|
||||
return $meta_robots;
|
||||
}
|
||||
|
||||
public static function header_count( $html, $header = 'h1' )
|
||||
{
|
||||
$dom = new \DOMDocument();
|
||||
@$dom -> loadHTML( $html );
|
||||
$headers = $dom -> getElementsByTagName( $header );
|
||||
return $headers -> length;
|
||||
}
|
||||
|
||||
public static function favicon( $html )
|
||||
{
|
||||
$dom = new \DOMDocument();
|
||||
@$dom -> loadHTML( $html );
|
||||
$links = $dom -> getElementsByTagName( 'link' );
|
||||
$favicon = '';
|
||||
|
||||
for ( $i = 0; $i < $links -> length; $i++ )
|
||||
{
|
||||
$link = $links -> item( $i );
|
||||
if ( $link -> getAttribute( 'rel' ) == 'icon' || $link -> getAttribute( 'rel' ) == "Shortcut Icon" || $link -> getAttribute( 'rel' ) == "shortcut icon" )
|
||||
$favicon = $link -> getAttribute( 'href' );
|
||||
}
|
||||
return $favicon;
|
||||
}
|
||||
|
||||
public static function flash_check( $html )
|
||||
{
|
||||
if ( strpos( $html, 'Get Adobe Flash player' ) !== false )
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function iframe_check( $html )
|
||||
{
|
||||
$dom = new \DOMDocument();
|
||||
@$dom -> loadHTML( $html );
|
||||
$iframes = $dom -> getElementsByTagName( 'iframe' );
|
||||
if ( $iframes -> length )
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function doctype( $html ) {
|
||||
if ( strpos( $html, 'HTML 4.01 Frameset//EN' ) !== false )
|
||||
return 'HTML 4.01 Frameset';
|
||||
elseif ( strpos( $html, 'HTML 4.01 Transitional//EN' ) !== false )
|
||||
return 'HTML 4.01 Transitional';
|
||||
elseif ( strpos( $html, 'HTML 4.01//EN' ) !== false )
|
||||
return 'HTML 4.01 Strict';
|
||||
else
|
||||
return 'HTML 5';
|
||||
}
|
||||
|
||||
public static function html_language( $html ) {
|
||||
$dom = new \DOMDocument();
|
||||
@$dom -> loadHTML( $html );
|
||||
$htmls = $dom -> getElementsByTagName( 'html' );
|
||||
|
||||
for ( $i = 0; $i < $htmls -> length; $i++ ) {
|
||||
$html = $htmls -> item( $i );
|
||||
return $html -> getAttribute( 'lang' );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function inline_css( $html ) {
|
||||
$dom = new \DOMDocument();
|
||||
@$dom -> loadHTML( $html );
|
||||
$spans = $dom -> getElementsByTagName( 'span' );
|
||||
for ( $i = 0; $i < $spans -> length; $i++ ) {
|
||||
$span = $spans -> item( $i );
|
||||
if ( $span -> getAttribute( 'style' ) != '' )
|
||||
return true;
|
||||
}
|
||||
|
||||
$ps = $dom -> getElementsByTagName( 'p' );
|
||||
for ( $i = 0; $i < $ps -> length; $i++ ) {
|
||||
$p = $ps -> item( $i );
|
||||
if ( $p -> getAttribute( 'style' ) != '' )
|
||||
return true;
|
||||
}
|
||||
|
||||
$divs = $dom -> getElementsByTagName( 'div' );
|
||||
for ( $i = 0; $i < $divs -> length; $i++ ) {
|
||||
$div = $divs -> item( $i );
|
||||
if ( $div -> getAttribute( 'style' ) != '' )
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function audit( $url )
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
if ( !$url )
|
||||
return false;
|
||||
|
||||
if ( strpos( $url, 'http://' ) === false and strpos( $url, 'https://' ) === false )
|
||||
$url = 'http://' . $url;
|
||||
|
||||
$url_tmp = parse_url( $url );
|
||||
$url = strip_tags( $url_tmp['host'] ) . $url_tmp['path'];
|
||||
if ( substr( $url, -1, 1 ) == '/')
|
||||
$url = substr( $url, 0, -1 );
|
||||
|
||||
if ( $mdb -> count( 'as_sites', [ 'url' => $url ] ) )
|
||||
return $url;
|
||||
else
|
||||
{
|
||||
$ch = curl_init();
|
||||
curl_setopt( $ch, CURLOPT_URL, $url );
|
||||
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
|
||||
curl_setopt( $ch, CURLOPT_VERBOSE, 1 );
|
||||
curl_setopt( $ch, CURLOPT_TIMEOUT, 60 );
|
||||
curl_setopt( $ch, CURLOPT_HEADER, true );
|
||||
curl_setopt( $ch, CURLOPT_CAINFO, 'cacert.pem' );
|
||||
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );
|
||||
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true );
|
||||
curl_setopt( $ch, CURLOPT_HEADER, false );
|
||||
curl_setopt( $ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.103 Safari/537.36' );
|
||||
$response = curl_exec( $ch );
|
||||
|
||||
$effective_url = curl_getinfo( $ch, CURLINFO_EFFECTIVE_URL );
|
||||
$ip = curl_getinfo( $ch, CURLINFO_PRIMARY_IP );
|
||||
$location = file_get_contents( "http://ipinfo.io/{$ip}/json" );
|
||||
$favicon = self::favicon( $response );
|
||||
$cms = self::cms( $response );
|
||||
$meta_robots = self::meta_robots( $response );
|
||||
$meta_title = self::meta_title( $response );
|
||||
$meta_description = self::meta_description( $response );
|
||||
$meta_keywords = self::meta_keywords( $response );
|
||||
$h1_count = self::header_count( $response, 'h1' );
|
||||
$h2_count = self::header_count( $response, 'h2' );
|
||||
$h3_count = self::header_count( $response, 'h3' );
|
||||
$h4_count = self::header_count( $response, 'h4' );
|
||||
$h5_count = self::header_count( $response, 'h5' );
|
||||
$h6_count = self::header_count( $response, 'h6' );
|
||||
$flash = self::flash_check( $response );
|
||||
$iframe = self::iframe_check( $response );
|
||||
$inline_css = self::inline_css( $response );
|
||||
$doctype = self::doctype( $response );
|
||||
$html_language = self::html_language( $response );
|
||||
|
||||
$html_length = strlen( $response );
|
||||
$text_length = strlen( strip_tags( $response ) );
|
||||
$code_length = $html_length - $text_length;
|
||||
|
||||
$words_count = str_word_count( strip_tags( $response ) );
|
||||
|
||||
curl_close ( $ch );
|
||||
|
||||
$ch = curl_init();
|
||||
curl_setopt( $ch, CURLOPT_URL, $effective_url . '/robots.txt' );
|
||||
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
|
||||
curl_setopt( $ch, CURLOPT_VERBOSE, 1 );
|
||||
curl_setopt( $ch, CURLOPT_TIMEOUT, 60 );
|
||||
curl_setopt( $ch, CURLOPT_HEADER, true );
|
||||
curl_setopt( $ch, CURLOPT_CAINFO, 'cacert.pem' );
|
||||
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );
|
||||
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true );
|
||||
curl_setopt( $ch, CURLOPT_HEADER, false );
|
||||
curl_setopt( $ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.103 Safari/537.36' );
|
||||
$robots_txt = curl_exec( $ch );
|
||||
|
||||
if ( curl_getinfo( $ch, CURLINFO_HTTP_CODE ) == 200 )
|
||||
$file_robots_txt = 1;
|
||||
else
|
||||
$file_robots_txt = 0;
|
||||
|
||||
curl_close ( $ch );
|
||||
|
||||
$ch = curl_init();
|
||||
curl_setopt( $ch, CURLOPT_URL, $effective_url . '/sitemap.xml' );
|
||||
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
|
||||
curl_setopt( $ch, CURLOPT_VERBOSE, 1 );
|
||||
curl_setopt( $ch, CURLOPT_TIMEOUT, 60 );
|
||||
curl_setopt( $ch, CURLOPT_HEADER, true );
|
||||
curl_setopt( $ch, CURLOPT_CAINFO, 'cacert.pem' );
|
||||
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );
|
||||
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true );
|
||||
curl_setopt( $ch, CURLOPT_HEADER, false );
|
||||
curl_setopt( $ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.103 Safari/537.36' );
|
||||
$sitemap_xml = curl_exec( $ch );
|
||||
|
||||
if ( curl_getinfo( $ch, CURLINFO_HTTP_CODE ) == 200 )
|
||||
$file_sitemap_xml = 1;
|
||||
else
|
||||
$file_sitemap_xml = 0;
|
||||
|
||||
curl_close ( $ch );
|
||||
|
||||
$url_parse = parse_url( $effective_url );
|
||||
$redirect_www = false;
|
||||
|
||||
if ( strpos( $effective_url, $url_parse['scheme'] . '://www.' ) !== false )
|
||||
{
|
||||
$ch = curl_init();
|
||||
curl_setopt( $ch, CURLOPT_URL, str_replace( $url_parse['scheme'] . '://www.', $url_parse['scheme'] . '://', $effective_url ) );
|
||||
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
|
||||
curl_setopt( $ch, CURLOPT_VERBOSE, 1 );
|
||||
curl_setopt( $ch, CURLOPT_TIMEOUT, 60 );
|
||||
curl_setopt( $ch, CURLOPT_HEADER, true );
|
||||
curl_setopt( $ch, CURLOPT_CAINFO, 'cacert.pem' );
|
||||
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );
|
||||
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true );
|
||||
curl_setopt( $ch, CURLOPT_HEADER, false );
|
||||
curl_setopt( $ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.103 Safari/537.36' );
|
||||
curl_exec( $ch );
|
||||
$effective_url_tmp = curl_getinfo( $ch, CURLINFO_EFFECTIVE_URL );
|
||||
curl_close ( $ch );
|
||||
|
||||
if ( $effective_url_tmp == $effective_url )
|
||||
$redirect_www = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$ch = curl_init();
|
||||
curl_setopt( $ch, CURLOPT_URL, str_replace( $url_parse['scheme'] . '://', $url_parse['scheme'] . '://www.', $effective_url ) );
|
||||
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
|
||||
curl_setopt( $ch, CURLOPT_VERBOSE, 1 );
|
||||
curl_setopt( $ch, CURLOPT_TIMEOUT, 60 );
|
||||
curl_setopt( $ch, CURLOPT_HEADER, true );
|
||||
curl_setopt( $ch, CURLOPT_CAINFO, 'cacert.pem' );
|
||||
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );
|
||||
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true );
|
||||
curl_setopt( $ch, CURLOPT_HEADER, false );
|
||||
curl_setopt( $ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.103 Safari/537.36' );
|
||||
curl_exec( $ch );
|
||||
$effective_url_tmp = curl_getinfo( $ch, CURLINFO_EFFECTIVE_URL );
|
||||
curl_close ( $ch );
|
||||
|
||||
if ( $effective_url_tmp == $effective_url )
|
||||
$redirect_www = true;
|
||||
}
|
||||
|
||||
$mdb -> insert( 'as_sites', [
|
||||
'url' => $url,
|
||||
'html' => $response,
|
||||
'effective_url' => $effective_url,
|
||||
'ip' => $ip,
|
||||
'location' => $location,
|
||||
'favicon' => $favicon,
|
||||
'cms' => $cms,
|
||||
'meta_robots' => $meta_robots,
|
||||
'robots_txt' => $robots_txt,
|
||||
'redirect_www' => $redirect_www ? 1 : 0,
|
||||
'https' => $url_parse['scheme'] == 'https' ? 1 : 0,
|
||||
'meta_title' => $meta_title,
|
||||
'meta_description' => $meta_description,
|
||||
'meta_keywords' => $meta_keywords,
|
||||
'code_length' => $code_length,
|
||||
'text_length' => $text_length,
|
||||
'words_count' => $words_count,
|
||||
'h1_count' => $h1_count,
|
||||
'h2_count' => $h2_count,
|
||||
'h3_count' => $h3_count,
|
||||
'h4_count' => $h4_count,
|
||||
'h5_count' => $h5_count,
|
||||
'h6_count' => $h6_count,
|
||||
'flash' => $flash ? 1 : 0,
|
||||
'iframe' => $iframe ? 1 : 0,
|
||||
'file_robots_txt' => $file_robots_txt,
|
||||
'file_sitemap_xml' => $file_sitemap_xml,
|
||||
'inline_css' => $inline_css,
|
||||
'doctype' => $doctype,
|
||||
'html_language' => $html_language
|
||||
] );
|
||||
|
||||
return $url;
|
||||
}
|
||||
}
|
||||
}
|
||||
22
autoload/front/factory/class.Authors.php
Normal file
22
autoload/front/factory/class.Authors.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?
|
||||
namespace front\factory;
|
||||
class Authors
|
||||
{
|
||||
// szczególy autora
|
||||
static public function get_single_author( $id_author )
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
if ( !$author = \Cache::fetch( "get_single_author:$id_author" ) )
|
||||
{
|
||||
$author = $mdb -> get( 'pp_authors', '*', [ 'id' => (int)$id_author ] );
|
||||
|
||||
$results = $mdb -> select( 'pp_authors_langs', '*', [ 'id_author' => (int)$id_author ] );
|
||||
if ( is_array( $results ) ) foreach ( $results as $row )
|
||||
$author['languages'][$row['id_lang']] = $row;
|
||||
|
||||
\Cache::store( "get_single_author:$id_author", $author );
|
||||
}
|
||||
return $author;
|
||||
}
|
||||
}
|
||||
63
autoload/front/factory/class.Banners.php
Normal file
63
autoload/front/factory/class.Banners.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
namespace front\factory;
|
||||
|
||||
class Banners
|
||||
{
|
||||
public static function banners()
|
||||
{
|
||||
global $mdb, $lang;
|
||||
|
||||
if ( !$banners = \Cache::fetch( 'banners' ) )
|
||||
{
|
||||
$results = $mdb -> query( 'SELECT '
|
||||
. 'id, name '
|
||||
. 'FROM '
|
||||
. 'pp_banners '
|
||||
. 'WHERE '
|
||||
. 'status = 1 '
|
||||
. 'AND '
|
||||
. '( date_start <= \'' . date( 'Y-m-d' ) . '\' OR date_start IS NULL ) '
|
||||
. 'AND '
|
||||
. '( date_end >= \'' . date( 'Y-m-d' ) . '\' OR date_end IS NULL ) '
|
||||
. 'AND '
|
||||
. 'home_page = 0' ) -> fetchAll();
|
||||
if ( is_array( $results ) and !empty( $results ) ) foreach ( $results as $row )
|
||||
{
|
||||
$row['languages'] = $mdb -> get( 'pp_banners_langs', '*', [ 'AND' => [ 'id_banner' => (int)$row['id'], 'id_lang' => $lang[0] ] ] );
|
||||
$banners[] = $row;
|
||||
}
|
||||
\Cache::store( 'banners', $banners );
|
||||
}
|
||||
return $banners;
|
||||
}
|
||||
|
||||
public static function main_banner()
|
||||
{
|
||||
global $mdb, $lang;
|
||||
|
||||
if ( !$banner = \Cache::fetch( "main_banner:" . $lang[0] ) )
|
||||
{
|
||||
$banner = $mdb -> query( 'SELECT '
|
||||
. '* '
|
||||
. 'FROM '
|
||||
. 'pp_banners '
|
||||
. 'WHERE '
|
||||
. 'status = 1 '
|
||||
. 'AND '
|
||||
. '( date_start <= \'' . date( 'Y-m-d' ) . '\' OR date_start IS NULL ) '
|
||||
. 'AND '
|
||||
. '( date_end >= \'' . date( 'Y-m-d' ) . '\' OR date_end IS NULL ) '
|
||||
. 'AND '
|
||||
. 'home_page = 1 '
|
||||
. 'ORDER BY '
|
||||
. 'date_end ASC '
|
||||
. 'LIMIT 1' ) -> fetchAll();
|
||||
$banner = $banner[0];
|
||||
if ( $banner )
|
||||
$banner['languages'] = $mdb -> get( 'pp_banners_langs', '*', [ 'AND' => [ 'id_banner' => (int)$banner['id'], 'id_lang' => $lang[0] ] ] );
|
||||
|
||||
\Cache::store( "main_banner:" . $lang[0], $banner );
|
||||
}
|
||||
return $banner;
|
||||
}
|
||||
}
|
||||
58
autoload/front/factory/class.Languages.php
Normal file
58
autoload/front/factory/class.Languages.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
namespace front\factory;
|
||||
|
||||
class Languages
|
||||
{
|
||||
public static function default_domain()
|
||||
{
|
||||
global $mdb;
|
||||
$results = $mdb -> query( 'SELECT domain FROM pp_langs WHERE status = 1 AND domain IS NOT NULL AND main_domain = 1' ) -> fetchAll();
|
||||
return $default_domain = $results[0][0];
|
||||
}
|
||||
|
||||
public static function default_language( $domain = '' )
|
||||
{
|
||||
global $mdb;
|
||||
if ( !$default_language = \Cache::fetch( "default_language:$domain" ) )
|
||||
{
|
||||
if ( $domain )
|
||||
$results = $mdb -> query( 'SELECT id FROM pp_langs WHERE status = 1 AND domain = \'' . $domain . '\' ORDER BY start DESC, o ASC LIMIT 1' ) -> fetchAll();
|
||||
if ( !$domain or !\front\factory\Languages::default_domain() )
|
||||
$results = $mdb -> query( 'SELECT id FROM pp_langs WHERE status = 1 AND domain IS NULL ORDER BY start DESC, o ASC LIMIT 1' ) -> fetchAll();
|
||||
$default_language = $results[0][0];
|
||||
|
||||
\Cache::store( "default_language:$domain", $default_language );
|
||||
}
|
||||
return $default_language;
|
||||
}
|
||||
|
||||
public static function active_languages()
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
if ( !$active_languages = \Cache::fetch( 'active_languages' ) )
|
||||
{
|
||||
$active_languages = $mdb -> select( 'pp_langs', [ 'id', 'name', 'domain' ], [ 'status' => 1, 'ORDER' => [ 'o' => 'ASC' ] ] );
|
||||
\Cache::store( 'active_languages', $active_languages );
|
||||
}
|
||||
return $active_languages;
|
||||
}
|
||||
|
||||
public static function lang_translations( $language = 'pl' )
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
if ( !$translations = \Cache::fetch( "lang_translations:$language" ) )
|
||||
{
|
||||
$translations[ '0' ] = $language;
|
||||
|
||||
$results = $mdb -> select( 'pp_langs_translations', [ 'text', $language ] );
|
||||
if ( is_array( $results ) ) foreach ( $results as $row )
|
||||
$translations[ $row['text'] ] = $row[ $language ];
|
||||
|
||||
\Cache::store( "lang_translations:$language", $translations );
|
||||
}
|
||||
|
||||
return $translations;
|
||||
}
|
||||
}
|
||||
53
autoload/front/factory/class.Layouts.php
Normal file
53
autoload/front/factory/class.Layouts.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
namespace front\factory;
|
||||
|
||||
class Layouts
|
||||
{
|
||||
public static function layout_details( $layout_id )
|
||||
{
|
||||
global $mdb, $cache;
|
||||
|
||||
if ( !$layout = \Cache::fetch( "layout_details:$layout_id" ) )
|
||||
{
|
||||
$layout = $mdb -> get( 'pp_layouts', '*', [ 'id' => (int)$layout_id ] );
|
||||
|
||||
if ( !$layout )
|
||||
$layout = $mdb -> get( 'pp_layouts', '*', [ 'status' => 1 ] );
|
||||
|
||||
\Cache::store( "layout_details:$layout_id", $layout );
|
||||
}
|
||||
return $layout;
|
||||
}
|
||||
|
||||
public static function article_layout( $article_id )
|
||||
{
|
||||
global $mdb, $cache;
|
||||
|
||||
if ( !$layout = \Cache::fetch( "article_layout:$article_id" ) )
|
||||
{
|
||||
$layout = $mdb -> get( 'pp_layouts', [ '[><]pp_articles' => [ 'id' => 'layout_id' ] ], '*', [ 'pp_articles.id' => (int)$article_id ] );
|
||||
|
||||
if ( !$layout )
|
||||
$layout = $mdb -> get( 'pp_layouts', '*', [ 'status' => 1 ] );
|
||||
|
||||
\Cache::store( "article_layout:$article_id", $layout );
|
||||
}
|
||||
return $layout;
|
||||
}
|
||||
|
||||
public static function active_layout( $page_id )
|
||||
{
|
||||
global $mdb, $cache;
|
||||
|
||||
if ( !$layout = \Cache::fetch( "active_layouts:$page_id" ) )
|
||||
{
|
||||
$layout = $mdb -> get( 'pp_layouts', [ '[><]pp_layouts_pages' => [ 'id' => 'layout_id' ] ], '*', [ 'page_id' => (int)$page_id ] );
|
||||
|
||||
if ( !$layout )
|
||||
$layout = $mdb -> get( 'pp_layouts', '*', [ 'status' => 1 ] );
|
||||
|
||||
\Cache::store( "active_layouts:$page_id", $layout );
|
||||
}
|
||||
return $layout;
|
||||
}
|
||||
}
|
||||
64
autoload/front/factory/class.Menu.php
Normal file
64
autoload/front/factory/class.Menu.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
namespace front\factory;
|
||||
|
||||
class Menu
|
||||
{
|
||||
public static function submenu_details( $page_id, $lang_id )
|
||||
{
|
||||
return self::subpages( $page_id, $lang_id );
|
||||
}
|
||||
|
||||
static public function subpages( $page_id, $lang_id )
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
if ( !$pages = \Cache::fetch( "subpages:$page_id:$lang_id" ) )
|
||||
{
|
||||
$results = $mdb -> select( 'pp_pages', [ 'id' ], [ 'AND' => [ 'status' => 1, 'parent_id' => $page_id ], 'ORDER' => [ 'o' => 'ASC' ] ] );
|
||||
if ( is_array( $results ) ) foreach ( $results as $row )
|
||||
{
|
||||
$page = \front\factory\Pages::page_details( $row['id'] );
|
||||
$page['pages'] = self::subpages( $row['id'], $lang_id );
|
||||
|
||||
$pages[] = $page;
|
||||
}
|
||||
|
||||
\Cache::store( "subpages:$page_id", $pages );
|
||||
}
|
||||
return $pages;
|
||||
}
|
||||
|
||||
public static function menu_details( $menu_id )
|
||||
{
|
||||
global $mdb, $lang_id;
|
||||
|
||||
if ( !$menu = \Cache::fetch( "menu_details:$menu_id:$lang_id" ) )
|
||||
{
|
||||
$menu = $mdb -> get( 'pp_menus', '*', [ 'id' => (int)$menu_id ] );
|
||||
$menu['pages'] = self::menu_pages( $menu_id );
|
||||
|
||||
\Cache::store( "menu_details:$menu_id:$lang_id", $menu );
|
||||
}
|
||||
return $menu;
|
||||
}
|
||||
|
||||
public static function menu_pages( $menu_id, $parent_id = null )
|
||||
{
|
||||
global $mdb, $lang_id;
|
||||
|
||||
if ( !$pages = \Cache::fetch( "menu_pages:$menu_id:$parent_id:$lang_id" ) )
|
||||
{
|
||||
$results = $mdb -> select( 'pp_pages', [ 'id' ], [ 'AND' => [ 'status' => 1, 'menu_id' => (int)$menu_id, 'parent_id' => $parent_id ], 'ORDER' => [ 'o' => 'ASC' ] ] );
|
||||
if ( is_array( $results ) ) foreach ( $results as $row )
|
||||
{
|
||||
$page = \front\factory\Pages::page_details( $row['id'] );
|
||||
$page['pages'] = self::menu_pages( $menu_id, $row['id'] );
|
||||
|
||||
$pages[] = $page;
|
||||
}
|
||||
|
||||
\Cache::store( "menu_pages:$menu_id:$parent_id:$lang_id", $pages );
|
||||
}
|
||||
return $pages;
|
||||
}
|
||||
}
|
||||
118
autoload/front/factory/class.Newsletter.php
Normal file
118
autoload/front/factory/class.Newsletter.php
Normal file
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
namespace front\factory;
|
||||
|
||||
class Newsletter
|
||||
{
|
||||
public static function newsletter_unsubscribe( $hash )
|
||||
{
|
||||
global $mdb;
|
||||
return $mdb -> update( 'pp_newsletter', [ 'status' => 0 ], [ 'hash' => $hash ] );
|
||||
}
|
||||
|
||||
public static function newsletter_confirm( $hash )
|
||||
{
|
||||
global $mdb;
|
||||
if ( !$id = $mdb -> get( 'pp_newsletter', 'id', [ 'AND' => [ 'hash' => $hash, 'status' => 0 ] ] ) )
|
||||
return false;
|
||||
else
|
||||
$mdb -> update( 'pp_newsletter', [ 'status' => 1 ], [ 'id' => $id ] );
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function newsletter_send( $limit = 5 )
|
||||
{
|
||||
global $mdb, $settings, $lang;
|
||||
|
||||
$results = $mdb -> query( 'SELECT * FROM pp_newsletter_send WHERE mailed = 0 ORDER BY id ASC LIMIT ' . $limit ) -> fetchAll();
|
||||
if ( is_array( $results ) and !empty( $results ) )
|
||||
{
|
||||
foreach ( $results as $row )
|
||||
{
|
||||
$dates = explode( ' - ', $row['dates'] );
|
||||
|
||||
$text = \admin\view\Newsletter::preview(
|
||||
\admin\factory\Articles::articles_by_date_add( $dates[0], $dates[1] ),
|
||||
\admin\factory\Settings::settings_details(),
|
||||
\admin\factory\Newsletter::email_template_detalis($row['id_template'])
|
||||
);
|
||||
|
||||
if ( $settings['ssl'] ) $base = 'https'; else $base = 'http';
|
||||
|
||||
$link = $base . "://" . $_SERVER['SERVER_NAME'] . '/newsletter/unsubscribe/hash=' . \front\factory\Newsletter::get_hash( $row['email'] );
|
||||
$text = str_replace( '[WYPISZ_SIE]', $link, $text );
|
||||
|
||||
$regex = "-(<img[^>]+src\s*=\s*['\"])(((?!'|\"|http(|s)://).)*)(['\"][^>]*>)-i";
|
||||
$text = preg_replace( $regex, "$1" . $base . "://" . $_SERVER['SERVER_NAME'] . "$2$4", $text );
|
||||
|
||||
$regex = "-(<a[^>]+href\s*=\s*['\"])(((?!'|\"|http(|s)://).)*)(['\"][^>]*>)-i";
|
||||
$text = preg_replace( $regex, "$1" . $base . "://" . $_SERVER['SERVER_NAME'] . "$2$4", $text );
|
||||
|
||||
\S::send_email( $row['email'], 'Newsletter ze strony: ' . $_SERVER['SERVER_NAME'], $text );
|
||||
|
||||
if ( $row['only_once'] )
|
||||
$mdb -> update( 'pp_newsletter_send', [ 'mailed' => 1 ], [ 'id' => $row['id'] ] );
|
||||
else
|
||||
$mdb -> delete( 'pp_newsletter_send', [ 'id' => $row['id'] ] );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function get_hash( $email )
|
||||
{
|
||||
global $mdb;
|
||||
return $mdb -> get( 'pp_newsletter', 'hash', [ 'email' => $email ] );
|
||||
}
|
||||
|
||||
public static function newsletter_signin( $email )
|
||||
{
|
||||
global $mdb, $lang, $settings;
|
||||
|
||||
if ( !\S::email_check( $email ) )
|
||||
return false;
|
||||
|
||||
if ( !$mdb -> get( 'pp_newsletter', 'id', [ 'email' => $email ] ) )
|
||||
{
|
||||
$hash = md5( time() . $email );
|
||||
|
||||
$text = $settings['newsletter_header'];
|
||||
$text .= \front\factory\Newsletter::get_template( '#potwierdzenie-zapisu-do-newslettera' );
|
||||
$text .= $settings['newsletter_footer_1'];
|
||||
|
||||
$settings['ssl'] ? $base = 'https' : $base = 'http';
|
||||
|
||||
$regex = "-(<img[^>]+src\s*=\s*['\"])(((?!'|\"|http://).)*)(['\"][^>]*>)-i";
|
||||
$text = preg_replace( $regex, "$1" . $base . "://" . $_SERVER['SERVER_NAME'] . "$2$4", $text );
|
||||
|
||||
$regex = "-(<a[^>]+href\s*=\s*['\"])(((?!'|\"|http://).)*)(['\"][^>]*>)-i";
|
||||
$text = preg_replace( $regex, "$1" . $base . "://" . $_SERVER['SERVER_NAME'] . "$2$4", $text );
|
||||
|
||||
$link = '/newsletter/confirm/hash=' . $hash;
|
||||
|
||||
$text = str_replace( '[LINK]', $link, $text );
|
||||
|
||||
$send = \S::send_email( $email, $lang['potwierdz-zapisanie-sie-do-newslettera'], $text );
|
||||
|
||||
$mdb -> insert( 'pp_newsletter', [ 'email' => $email, 'hash' => $hash, 'status' => 0 ] );
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function get_template( $template_name )
|
||||
{
|
||||
global $mdb;
|
||||
return $mdb -> get( 'pp_newsletter_templates', 'text', [ 'name' => $template_name ] );
|
||||
}
|
||||
|
||||
public static function newsletter_signout( $email )
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
if ( $mdb -> get( 'pp_newsletter', 'id', [ 'email' => $email ] ) )
|
||||
return $mdb -> delete( 'pp_newsletter', [ 'email' => $email ] );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
81
autoload/front/factory/class.Pages.php
Normal file
81
autoload/front/factory/class.Pages.php
Normal file
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
namespace front\factory;
|
||||
|
||||
class Pages
|
||||
{
|
||||
public static function page_sort( $page_id )
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
if ( !$sort = \Cache::fetch( "page_sort:$page_id" ) )
|
||||
{
|
||||
$sort = $mdb -> get( 'pp_pages', 'sort_type', [ 'id' => $page_id ] );
|
||||
|
||||
\Cache::store( "page_sort:$page_id", $sort );
|
||||
}
|
||||
return $sort;
|
||||
}
|
||||
|
||||
public static function lang_url( $page_id, $lang_id_t, $domain = '', $default_domain = '' )
|
||||
{
|
||||
$page = self::page_details( $page_id, $lang_id_t );
|
||||
|
||||
$page['language']['seo_link'] ? $url = '/' . $page['language']['seo_link'] : $url = '/s-' . $page['id'] . '-' . \S::seo( $page['language']['title'] );
|
||||
|
||||
if ( $lang_id_t == \S::get_session( 'current-lang' ) and !$default_domain and $lang_id_t == \front\factory\Languages::default_language( $domain ) )
|
||||
return $url;
|
||||
|
||||
if ( $domain and $lang_id_t != \S::get_session( 'current-lang' ) )
|
||||
return 'http://' . $domain . $url;
|
||||
|
||||
if ( !$domain && $default_domain )
|
||||
{
|
||||
if ( $lang_id_t != \front\factory\Languages::default_language( $default_domain ) and $url != '#' )
|
||||
$url = '/' . $lang_id_t . $url;
|
||||
|
||||
return 'http://' . $default_domain . $url;
|
||||
}
|
||||
|
||||
if ( $lang_id_t != \front\factory\Languages::default_language( $domain ) and $url != '#' )
|
||||
$url = '/' . $lang_id_t . $url;
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
public static function page_details( $id = '', $lang_tmp = '' )
|
||||
{
|
||||
global $mdb, $lang_id;
|
||||
|
||||
$page_lang = $lang_id;
|
||||
|
||||
if ( !$id )
|
||||
$id = self::main_page_id();
|
||||
|
||||
if ( $lang_tmp )
|
||||
$page_lang = $lang_tmp;
|
||||
|
||||
if ( !$page = \Cache::fetch( "page_details:$page_lang:$id" ) )
|
||||
{
|
||||
$page = $mdb -> get( 'pp_pages', '*', [ 'id' => (int)$id ] );
|
||||
$page['language'] = $mdb -> get( 'pp_pages_langs', '*', [ 'AND' => [ 'page_id' => (int)$id, 'lang_id' => $page_lang ] ] );
|
||||
|
||||
\Cache::store( "page_details:$page_lang:$id", $page );
|
||||
}
|
||||
|
||||
return $page;
|
||||
}
|
||||
|
||||
public static function main_page_id()
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
if ( !$id = \Cache::fetch( 'main_page_id' ) )
|
||||
{
|
||||
$id = $mdb -> get( 'pp_pages', 'id', [ 'AND' => [ 'status' => 1, 'start' => 1 ] ] );
|
||||
if ( !$id )
|
||||
$id = $mdb -> get( 'pp_pages', 'id', [ 'status' => 1, 'ORDER' => [ 'menu_id' => 'ASC', 'o' => 'ASC' ], 'LIMIT' => 1 ] );
|
||||
\Cache::store( 'main_page_id', $id );
|
||||
}
|
||||
return $id;
|
||||
}
|
||||
}
|
||||
23
autoload/front/factory/class.Scontainers.php
Normal file
23
autoload/front/factory/class.Scontainers.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
namespace front\factory;
|
||||
|
||||
class Scontainers
|
||||
{
|
||||
public static function scontainer_details( $scontainer_id )
|
||||
{
|
||||
global $mdb, $lang;
|
||||
|
||||
if ( !$scontainer = \Cache::fetch( "scontainer_details:$scontainer_id:" . $lang[0] ) )
|
||||
{
|
||||
$scontainer = $mdb -> get( 'pp_scontainers', '*', [ 'id' => (int)$scontainer_id ] );
|
||||
|
||||
$results = $mdb -> select( 'pp_scontainers_langs', '*', [ 'AND' => [ 'container_id' => (int)$scontainer_id, 'lang_id' => $lang[0] ] ] );
|
||||
if ( is_array( $results ) ) foreach ( $results as $row )
|
||||
$scontainer['languages'] = $row;
|
||||
|
||||
\Cache::store( "scontainer_details:$scontainer_id:" . $lang[0], $scontainer );
|
||||
}
|
||||
|
||||
return $scontainer;
|
||||
}
|
||||
}
|
||||
74
autoload/front/factory/class.Search.php
Normal file
74
autoload/front/factory/class.Search.php
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
namespace front\factory;
|
||||
|
||||
class Search
|
||||
{
|
||||
public static function search_results( $search_txt, $lang_id )
|
||||
{
|
||||
global $mdb, $cache;
|
||||
|
||||
if ( strlen( $search_txt ) < 3 )
|
||||
return false;
|
||||
|
||||
if ( !$articles = \Cache::fetch( "search_results:$search_txt:$lang_id" ) )
|
||||
{
|
||||
$results = $mdb -> query( 'SELECT * FROM ( '
|
||||
. 'SELECT '
|
||||
. 'a.id, '
|
||||
. '( CASE '
|
||||
. 'WHEN copy_from IS NULL THEN title '
|
||||
. 'WHEN copy_from IS NOT NULL THEN ( '
|
||||
. 'SELECT '
|
||||
. 'title '
|
||||
. 'FROM '
|
||||
. 'pp_articles_langs '
|
||||
. 'WHERE '
|
||||
. 'lang_id = al.copy_from AND article_id = a.id '
|
||||
. ') '
|
||||
. 'END ) AS title, '
|
||||
. '( CASE '
|
||||
. 'WHEN copy_from IS NULL THEN entry '
|
||||
. 'WHEN copy_from IS NOT NULL THEN ( '
|
||||
. 'SELECT '
|
||||
. 'entry '
|
||||
. 'FROM '
|
||||
. 'pp_articles_langs '
|
||||
. 'WHERE '
|
||||
. 'lang_id = al.copy_from AND article_id = a.id '
|
||||
. ') '
|
||||
. 'END ) AS entry, '
|
||||
. '( CASE '
|
||||
. 'WHEN copy_from IS NULL THEN text '
|
||||
. 'WHEN copy_from IS NOT NULL THEN ( '
|
||||
. 'SELECT '
|
||||
. 'text '
|
||||
. 'FROM '
|
||||
. 'pp_articles_langs '
|
||||
. 'WHERE '
|
||||
. 'lang_id = al.copy_from AND article_id = a.id '
|
||||
. ') '
|
||||
. 'END ) AS text '
|
||||
. 'FROM '
|
||||
. 'pp_articles AS a '
|
||||
. 'INNER JOIN pp_articles_langs AS al ON a.id = al.article_id '
|
||||
. 'WHERE '
|
||||
. 'status = 1 AND lang_id = \'' . $lang_id . '\' '
|
||||
. ') AS q1 '
|
||||
. 'WHERE '
|
||||
. 'q1.title IS NOT NULL '
|
||||
. 'AND '
|
||||
. '( '
|
||||
. 'LOWER( title ) LIKE \'%' . \S::escape( strtolower( $search_txt ) ) . '%\' '
|
||||
. 'OR '
|
||||
. 'LOWER( entry ) LIKE \'%' . \S::escape( strtolower( $search_txt ) ) . '%\' '
|
||||
. 'OR '
|
||||
. 'LOWER( text ) LIKE \'%' . \S::escape( strtolower( $search_txt ) ) . '%\' '
|
||||
. ')' ) -> fetchAll();
|
||||
if ( is_array( $results ) and !empty( $results ) ) foreach ( $results as $row )
|
||||
$articles[] = \front\factory\Articles::article_details( $row['id'], $lang_id );
|
||||
|
||||
\Cache::store( "search_results:$search_txt:$lang_id", $articles );
|
||||
}
|
||||
return $articles;
|
||||
}
|
||||
}
|
||||
10
autoload/front/factory/class.SeoAdditional.php
Normal file
10
autoload/front/factory/class.SeoAdditional.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
namespace front\factory;
|
||||
class SeoAdditional
|
||||
{
|
||||
public static function seo_active()
|
||||
{
|
||||
global $mdb;
|
||||
return $mdb -> select( 'pp_seo_additional', '*', [ 'status' => 1 ] );
|
||||
}
|
||||
}
|
||||
27
autoload/front/factory/class.Settings.php
Normal file
27
autoload/front/factory/class.Settings.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
namespace front\factory;
|
||||
|
||||
class Settings
|
||||
{
|
||||
public static function settings_details()
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
if ( !$settings = \Cache::fetch( 'settings_details' ) )
|
||||
{
|
||||
$results = $mdb -> select( 'pp_settings', '*' );
|
||||
if ( is_array( $results ) ) foreach ( $results as $row )
|
||||
$settings[ $row['param'] ] = $row['value'];
|
||||
|
||||
\Cache::store( 'settings_details', $settings );
|
||||
}
|
||||
|
||||
return $settings;
|
||||
}
|
||||
|
||||
public static function visit_counter()
|
||||
{
|
||||
global $mdb;
|
||||
return $mdb -> get( 'pp_settings', 'value', [ 'param' => 'visits'] );
|
||||
}
|
||||
}
|
||||
149
autoload/front/view/class.Articles.php
Normal file
149
autoload/front/view/class.Articles.php
Normal file
@@ -0,0 +1,149 @@
|
||||
<?php
|
||||
namespace front\view;
|
||||
|
||||
class Articles
|
||||
{
|
||||
public static function password_view( $values )
|
||||
{
|
||||
$tpl = new \Tpl;
|
||||
if ( is_array( $values ) ) foreach ( $values as $key => $val )
|
||||
$tpl -> $key = $val;
|
||||
return $tpl -> render( 'articles/password-view' );
|
||||
}
|
||||
|
||||
public static function map( $settings, $map_counter )
|
||||
{
|
||||
$tpl = new \Tpl;
|
||||
$tpl -> settings = $settings;
|
||||
$tpl -> map_counter = $map_counter;
|
||||
return $tpl -> render( 'articles/map' );
|
||||
}
|
||||
|
||||
public static function tags_cloud()
|
||||
{
|
||||
global $settings;
|
||||
|
||||
if ( !$settings['tags'] )
|
||||
return false;
|
||||
|
||||
$tpl = new \Tpl;
|
||||
$tpl -> tags = \front\factory\Articles::tags();
|
||||
return $tpl -> render( 'articles/tags-cloud' );
|
||||
}
|
||||
|
||||
public static function news( $page_id, $articles, $template = '' )
|
||||
{
|
||||
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;
|
||||
if ( is_array( $values ) ) foreach ( $values as $key => $val )
|
||||
$tpl -> $key = $val;
|
||||
return $tpl -> render( 'articles/article' );
|
||||
}
|
||||
|
||||
public static function article_full( $article_id, $lang_id )
|
||||
{
|
||||
$tpl = new \Tpl;
|
||||
$tpl -> article = \front\factory\Articles::article_details( $article_id, $lang_id );
|
||||
return $tpl -> render( 'articles/article-full' );
|
||||
}
|
||||
|
||||
public static function miniature_articles_list( $page, $lang_id, $bs = 1 )
|
||||
{
|
||||
$results = \front\factory\Articles::page_articles( $page, $lang_id, $bs );
|
||||
|
||||
if ( is_array( $results['articles'] ) ) foreach ( $results['articles'] as $article )
|
||||
$articles[] = \front\factory\Articles::article_details( $article, $lang_id );
|
||||
|
||||
$tpl = new \Tpl;
|
||||
$tpl -> page_id = $page['id'];
|
||||
$tpl -> articles = $articles;
|
||||
$out .= $tpl -> render( 'articles/articles-miniatures' );
|
||||
|
||||
if ( $results['ls'] > 1 )
|
||||
{
|
||||
$tpl = new \Tpl;
|
||||
$tpl -> ls = $results['ls'];
|
||||
$tpl -> bs = $bs ? $bs : 1;
|
||||
$tpl -> page = $page;
|
||||
$out .= $tpl -> render( 'site/pager' );
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
public static function entry_articles_list( $page, $lang_id, $bs = 1 )
|
||||
{
|
||||
global $page;
|
||||
|
||||
$results = \front\factory\Articles::page_articles( $page, $lang_id, $bs );
|
||||
|
||||
if ( is_array( $results['articles'] ) ) foreach ( $results['articles'] as $article )
|
||||
$articles[] = \front\factory\Articles::article_details( $article, $lang_id );
|
||||
|
||||
$tpl = new \Tpl;
|
||||
$tpl -> page_id = $page['id'];
|
||||
$tpl -> articles = $articles;
|
||||
$out .= $tpl -> render( 'articles/articles-entries' );
|
||||
|
||||
if ( $results['ls'] > 1 )
|
||||
{
|
||||
$tpl = new \Tpl;
|
||||
$tpl -> ls = $results['ls'];
|
||||
$tpl -> bs = $bs ? $bs : 1;
|
||||
$tpl -> page = $page;
|
||||
$out .= $tpl -> render( 'site/pager' );
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
public static function full_articles_list( $page, $lang_id, $bs = 1 )
|
||||
{
|
||||
$results = \front\factory\Articles::page_articles( $page, $lang_id, $bs );
|
||||
|
||||
if ( is_array( $results['articles'] ) ) foreach ( $results['articles'] as $article )
|
||||
{
|
||||
$article_details = \front\factory\Articles::article_details( $article, $lang_id );
|
||||
|
||||
if ( $article_details['password'] and !\S::get_session( 'article-' . $article . '-' . $article_details['password'] ) )
|
||||
$out .= \front\view\Articles::password_view( [ 'article' => $article ] );
|
||||
else
|
||||
{
|
||||
$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;
|
||||
$tpl -> ls = $results['ls'];
|
||||
$tpl -> bs = $bs ? $bs : 1;
|
||||
$tpl -> page = $page;
|
||||
$out .= $tpl -> render( 'site/pager' );
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
35
autoload/front/view/class.Banners.php
Normal file
35
autoload/front/view/class.Banners.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
namespace front\view;
|
||||
|
||||
class Banners
|
||||
{
|
||||
public static function banners( $banners )
|
||||
{
|
||||
$tpl = new \Tpl;
|
||||
$tpl -> banners = $banners;
|
||||
return $tpl -> render( 'banner/banners' );
|
||||
}
|
||||
|
||||
public static function main_banner( $banner )
|
||||
{
|
||||
if ( file_exists( 'templates/banner/draw.php' ) and !file_exists( 'templates/banner/main-banner.php' ) )
|
||||
copy( 'templates/banner/draw.php', 'templates/banner/main-banner.php' );
|
||||
|
||||
if ( file_exists( 'templates/banner/draw.php' ) and file_exists( 'templates/banner/main-banner.php' ) )
|
||||
unlink( 'templates/banner/draw.php' );
|
||||
|
||||
if ( file_exists( 'templates_user/banner/draw.php' ) and !file_exists( 'templates_user/banner/main-banner.php' ) )
|
||||
copy( 'templates_user/banner/draw.php', 'templates_user/banner/main-banner.php' );
|
||||
|
||||
if ( file_exists( 'templates_user/banner/draw.php' ) and file_exists( 'templates_user/banner/main-banner.php' ) )
|
||||
unlink( 'templates_user/banner/draw.php' );
|
||||
|
||||
|
||||
if ( !\S::get_session( 'banner_close' ) && is_array( $banner ) )
|
||||
{
|
||||
$tpl = new \Tpl;
|
||||
$tpl -> banner = $banner;
|
||||
return $tpl -> render( 'banner/main-banner' );
|
||||
}
|
||||
}
|
||||
}
|
||||
13
autoload/front/view/class.Languages.php
Normal file
13
autoload/front/view/class.Languages.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
namespace front\view;
|
||||
|
||||
class Languages
|
||||
{
|
||||
public static function languages()
|
||||
{
|
||||
$tpl = new \Tpl;
|
||||
$tpl -> languages = \front\factory\Languages::active_languages();
|
||||
$tpl -> default_domain = \front\factory\Languages::default_domain();
|
||||
return $tpl -> render( 'site/languages' );
|
||||
}
|
||||
}
|
||||
42
autoload/front/view/class.Menu.php
Normal file
42
autoload/front/view/class.Menu.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
namespace front\view;
|
||||
|
||||
class Menu
|
||||
{
|
||||
public static function pages( $pages, $level = 0, $current_page = 0 )
|
||||
{
|
||||
$tpl = new \Tpl;
|
||||
$tpl -> pages = $pages;
|
||||
$tpl -> level = $level;
|
||||
$tpl -> current_page = $current_page;
|
||||
return $tpl -> render( 'menu/pages' );
|
||||
}
|
||||
|
||||
public static function main_menu( $menu, $current_page )
|
||||
{
|
||||
|
||||
$tpl = new \Tpl;
|
||||
$tpl -> menu = $menu;
|
||||
$tpl -> current_page = $current_page;
|
||||
return $tpl -> render( 'menu/main-menu' );
|
||||
}
|
||||
|
||||
public static function menu( $menu, $current_page )
|
||||
{
|
||||
|
||||
$tpl = new \Tpl;
|
||||
$tpl -> menu = $menu;
|
||||
$tpl -> current_page = $current_page;
|
||||
return $tpl -> render( 'menu/menu' );
|
||||
}
|
||||
|
||||
public static function submenu( $pages, $current_page, $page_id, $level = 0 )
|
||||
{
|
||||
$tpl = new \Tpl;
|
||||
$tpl -> page_id = $page_id;
|
||||
$tpl -> pages = $pages;
|
||||
$tpl -> current_page = $current_page;
|
||||
$tpl -> level = $level;
|
||||
return $tpl -> render( 'menu/submenu' );
|
||||
}
|
||||
}
|
||||
11
autoload/front/view/class.Newsletter.php
Normal file
11
autoload/front/view/class.Newsletter.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
namespace front\view;
|
||||
|
||||
class Newsletter
|
||||
{
|
||||
public static function newsletter()
|
||||
{
|
||||
$tpl = new \Tpl;
|
||||
return $tpl -> render( 'newsletter/newsletter' );
|
||||
}
|
||||
}
|
||||
12
autoload/front/view/class.Scontainers.php
Normal file
12
autoload/front/view/class.Scontainers.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
namespace front\view;
|
||||
|
||||
class Scontainers
|
||||
{
|
||||
public static function scontainer( $id )
|
||||
{
|
||||
$tpl = new \Tpl;
|
||||
$tpl -> scontainer = \front\factory\Scontainers::scontainer_details( $id );
|
||||
return $tpl -> render( 'scontainers/scontainer' );
|
||||
}
|
||||
}
|
||||
18
autoload/front/view/class.Search.php
Normal file
18
autoload/front/view/class.Search.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
namespace front\view;
|
||||
|
||||
class Search
|
||||
{
|
||||
public static function search_results( $articles )
|
||||
{
|
||||
$tpl = new \Tpl;
|
||||
$tpl -> articles = $articles;
|
||||
return $tpl -> render( 'search/search-results' );
|
||||
}
|
||||
|
||||
public static function search_form()
|
||||
{
|
||||
$tpl = new \Tpl;
|
||||
return $tpl -> render( 'search/search-form' );
|
||||
}
|
||||
}
|
||||
408
autoload/front/view/class.Site.php
Normal file
408
autoload/front/view/class.Site.php
Normal file
@@ -0,0 +1,408 @@
|
||||
<?php
|
||||
|
||||
namespace front\view;
|
||||
|
||||
class Site
|
||||
{
|
||||
const menu_pattern = '/MENU:[0-9]*/';
|
||||
const main_menu_pattern = '/MENU_GLOWNE:[0-9]*/';
|
||||
const submenu_pattern = '/SUBMENU:[0-9]*/';
|
||||
const container_pattern = '/KONTENER:[0-9]*/';
|
||||
const language_pattern = '/LANG:[a-zA-Z0-9_-]*/';
|
||||
const news_pattern = '/AKTUALNOSCI:([0-9]+)(?::([0-9]*))?(?::([^:\]]+))?/';
|
||||
const news_list_pattern = '/AKTUALNOSCI_LISTA:([0-9]*)((:([0-9]*))?)/';
|
||||
const top_news_pattern = '/NAJPOULARNIEJSZE_ARTYKULY:([0-9]*)((:([0-9]*))?)/';
|
||||
const article_pattern = '/ARTYKUL:[0-9]*/';
|
||||
const maps_pattern = '/\[MAPA](.*)\[\/MAPA]/';
|
||||
|
||||
public static function show()
|
||||
{
|
||||
global $page, $settings, $lang_id;
|
||||
|
||||
$settings['link_version'] ? $www = 'www.' : $www = '';
|
||||
$settings['ssl'] == true ? $domain_prefix = 'https' : $domain_prefix = 'http';
|
||||
$url = preg_replace('#^(http(s)?://)?w{3}\.#', '$1', $_SERVER['SERVER_NAME']);
|
||||
|
||||
if (\S::get('article'))
|
||||
$layout = \front\factory\Layouts::article_layout(\S::get('article'));
|
||||
|
||||
if (!$layout)
|
||||
$layout = \front\factory\Layouts::active_layout($page['id']);
|
||||
|
||||
if (\S::get('layout_id'))
|
||||
$layout = \front\factory\Layouts::layout_details(\S::get('layout_id'));
|
||||
|
||||
if ($settings['devel'] == true and file_exists('devel.html'))
|
||||
$html = file_get_contents('devel.html');
|
||||
else
|
||||
{
|
||||
if (\S::is_mobile() and !empty($layout['m_html']))
|
||||
$html = $layout['m_html'];
|
||||
else
|
||||
$html = $layout['html'];
|
||||
}
|
||||
|
||||
\S::set_session('layout_id', $layout['layout_id'] ? $layout['layout_id'] : $layout['id']);
|
||||
|
||||
if ($settings['google_search_console'])
|
||||
$html = str_replace('</head>', '<meta name="google-site-verification" content="' . $settings['google_search_console'] . '"></head>', $html);
|
||||
|
||||
if (\S::get_session('contrast'))
|
||||
$html = str_replace('</head>', '<link rel="stylesheet" type="text/css" href="/layout/contrast.css"></head>', $html);
|
||||
|
||||
if ($settings['facebook_link'])
|
||||
$html = str_replace('</body>', \front\view\Site::facebook($settings['facebook_link']) . '</body>', $html);
|
||||
|
||||
if (strpos($html, '[BANER_STRONA_GLOWNA]') === false)
|
||||
$html = str_replace('</body>', '[BANER_STRONA_GLOWNA]' . '</body>', $html);
|
||||
|
||||
if (strpos($html, '[WIDGET_TELEFON]') === false)
|
||||
$html = str_replace('</body>', '[WIDGET_TELEFON]' . '</body>', $html);
|
||||
|
||||
if ($settings['ssl'] == true)
|
||||
{
|
||||
$layout['css'] = str_replace('http://', 'https://', $layout['css']);
|
||||
$layout['js'] = str_replace('http://', 'https://', $layout['js']);
|
||||
$layout['m_css'] = str_replace('http://', 'https://', $layout['m_css']);
|
||||
$layout['m_js'] = str_replace('http://', 'https://', $layout['m_js']);
|
||||
}
|
||||
|
||||
$html = str_replace('[COPYRIGHT]', \front\view\Site::copyright(), $html);
|
||||
$html = str_replace('[BANER_STRONA_GLOWNA]', \front\view\Banners::main_banner(\front\factory\Banners::main_banner()), $html);
|
||||
$html = str_replace('[BANERY]', \front\view\Banners::banners(\front\factory\Banners::banners()), $html);
|
||||
$html = str_replace('[LICZNIK_ODWIEDZIN]', \front\view\Site::visit_counter(\S::get_session('visits')), $html);
|
||||
$html = str_replace('[WYSZUKIWARKA]', \front\view\Search::search_form(), $html);
|
||||
$html = str_replace('[CHMURA_TAGOW]', \front\view\Articles::tags_cloud(), $html);
|
||||
$html = str_replace('[KONTRAST]', \front\view\Site::contrast(), $html);
|
||||
$html = str_replace('[NEWSLETTER]', \front\view\Newsletter::newsletter(), $html);
|
||||
$html = str_replace('[WIDGET_TELEFON]', $settings['widget_phone'] == 1 ? \front\view\Site::widget_phone() : '', $html);
|
||||
|
||||
if (\S::is_mobile() and !empty($layout['m_html']))
|
||||
$html = str_replace('[CSS]', $layout['m_css'], $html);
|
||||
else
|
||||
$html = str_replace('[CSS]', $layout['css'], $html);
|
||||
|
||||
if (\S::is_mobile() and !empty($layout['m_html']))
|
||||
$html = str_replace('[JAVA_SCRIPT]', $layout['m_js'], $html);
|
||||
else
|
||||
$html = str_replace('[JAVA_SCRIPT]', $layout['js'], $html);
|
||||
|
||||
preg_match_all(self::menu_pattern, $html, $menu);
|
||||
if (is_array($menu[0])) foreach ($menu[0] as $menu_tmp)
|
||||
{
|
||||
$menu_tmp = explode(':', $menu_tmp);
|
||||
$html = str_replace('[MENU:' . $menu_tmp[1] . ']', \front\view\Menu::menu(
|
||||
\front\factory\Menu::menu_details($menu_tmp[1]),
|
||||
$page['id']
|
||||
), $html);
|
||||
}
|
||||
|
||||
preg_match_all(self::main_menu_pattern, $html, $menu);
|
||||
if (is_array($menu[0])) foreach ($menu[0] as $menu_tmp)
|
||||
{
|
||||
$menu_tmp = explode(':', $menu_tmp);
|
||||
$html = str_replace('[MENU_GLOWNE:' . $menu_tmp[1] . ']', \front\view\Menu::main_menu(
|
||||
\front\factory\Menu::menu_details($menu_tmp[1]),
|
||||
$page['id']
|
||||
), $html);
|
||||
}
|
||||
|
||||
preg_match_all(self::submenu_pattern, $html, $submenu);
|
||||
if (is_array($submenu[0])) foreach ($submenu[0] as $submenu_tmp)
|
||||
{
|
||||
$submenu_tmp = explode(':', $submenu_tmp);
|
||||
$html = str_replace('[SUBMENU:' . $submenu_tmp[1] . ']', \front\view\Menu::submenu(
|
||||
\front\factory\Menu::submenu_details($submenu_tmp[1], $lang_id),
|
||||
$page['id'],
|
||||
$submenu_tmp[1]
|
||||
), $html);
|
||||
}
|
||||
|
||||
preg_match_all(self::container_pattern, $html, $container_list);
|
||||
if (is_array($container_list[0])) foreach ($container_list[0] as $container_list_tmp)
|
||||
{
|
||||
$container_list_tmp = explode(':', $container_list_tmp);
|
||||
$html = str_replace('[KONTENER:' . $container_list_tmp[1] . ']', \front\view\Scontainers::scontainer($container_list_tmp[1]), $html);
|
||||
}
|
||||
|
||||
$html = str_replace('[ZAWARTOSC]', \front\controls\Site::route(), $html);
|
||||
|
||||
preg_match_all( self::news_pattern, $html, $news_list );
|
||||
if ( is_array( $news_list[0] ) )
|
||||
{
|
||||
foreach ( $news_list[0] as $index => $news_list_tmp )
|
||||
{
|
||||
$id = $news_list[1][$index];
|
||||
$limit = $news_list[2][$index] ?: $settings['news_limit'];
|
||||
$extra = $news_list[3][$index] ?? '';
|
||||
|
||||
$pattern_parts = ['AKTUALNOSCI', $id];
|
||||
if ($news_list[2][$index] !== '') $pattern_parts[] = $limit;
|
||||
if ($extra !== '') $pattern_parts[] = $extra;
|
||||
$pattern = '[' . implode(':', $pattern_parts) . ']';
|
||||
|
||||
$html = str_replace(
|
||||
$pattern,
|
||||
\front\view\Articles::news( $id, \front\factory\Articles::news( $id, $limit, $lang_id ), $extra ),
|
||||
$html
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// prosta lista aktualności z wybranej podstrony
|
||||
preg_match_all(self::news_list_pattern, $html, $news_list);
|
||||
if (is_array($news_list[0])) foreach ($news_list[0] as $news_list_tmp)
|
||||
{
|
||||
$news_list_tmp = explode(':', $news_list_tmp);
|
||||
$news_list_tmp[2] != '' ? $news_limit = $news_list_tmp[2] : $news_limit = $settings['news_limit'];
|
||||
$news_list_tmp[2] != '' ? $pattern = '[AKTUALNOSCI_LISTA:' . $news_list_tmp[1] . ':' . $news_list_tmp[2] . ']' : $pattern = '[AKTUALNOSCI_LISTA:' . $news_list_tmp[1] . ']';
|
||||
|
||||
$news_list = \Article::getNews($news_list_tmp[1], $news_limit, $lang_id);
|
||||
$view_news_list = \Article::newsList($news_list);
|
||||
$html = str_replace($pattern, $view_news_list, $html);
|
||||
}
|
||||
|
||||
// prosta lista z najpopularniejszymi artykułami
|
||||
preg_match_all(self::top_news_pattern, $html, $news_list);
|
||||
if (is_array($news_list[0])) foreach ($news_list[0] as $news_list_tmp)
|
||||
{
|
||||
$news_list_tmp = explode(':', $news_list_tmp);
|
||||
$news_list_tmp[2] != '' ? $news_limit = $news_list_tmp[2] : $news_limit = $settings['news_limit'];
|
||||
$news_list_tmp[2] != '' ? $pattern = '[NAJPOULARNIEJSZE_ARTYKULY:' . $news_list_tmp[1] . ':' . $news_list_tmp[2] . ']' : $pattern = '[NAJPOULARNIEJSZE_ARTYKULY:' . $news_list_tmp[1] . ']';
|
||||
|
||||
$news_list = \Article::getTopNews($news_list_tmp[1], $news_limit, $lang_id);
|
||||
$view_news_list = \Article::newsList($news_list);
|
||||
$html = str_replace($pattern, $view_news_list, $html);
|
||||
}
|
||||
|
||||
preg_match_all(self::language_pattern, $html, $language_list);
|
||||
if (is_array($language_list[0])) foreach ($language_list[0] as $language_list_tmp)
|
||||
{
|
||||
$language_list_tmp = explode(':', $language_list_tmp);
|
||||
$html = str_replace('[LANG:' . $language_list_tmp[1] . ']', \S::lang($language_list_tmp[1]), $html);
|
||||
}
|
||||
|
||||
if (\S::get('article'))
|
||||
{
|
||||
$article = \front\factory\Articles::article_details(\S::get('article'), $lang_id);
|
||||
|
||||
$title = $article['language']['meta_title'] ? $article['language']['meta_title'] : $article['language']['title'];
|
||||
$meta_keywords = $article['language']['meta_keywords'];
|
||||
$meta_description = $article['language']['meta_description'];
|
||||
$og_image = $article['language']['main_image'] ? $article['language']['main_image'] : null;
|
||||
}
|
||||
else if (\S::get('tag'))
|
||||
{
|
||||
$tag = \front\factory\Articles::tag_details(\S::get('tag'));
|
||||
|
||||
$title = 'Tag: ' . $tag['name'];
|
||||
$meta_keywords = $tag['name'];
|
||||
$meta_description = 'Artykuły oznaczone tagiem: ' . $tag['name'];
|
||||
}
|
||||
else if (\S::get('search'))
|
||||
{
|
||||
$title = 'Wyniki wyszukiwania: ' . \S::get_session('search_txt');
|
||||
$meta_keywords = \S::get_session('search_txt');
|
||||
$meta_description = 'Wyniki wyszukiwania: ' . \S::get_session('search_txt');
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($page['language']['meta_title'])
|
||||
$title = $page['language']['meta_title'];
|
||||
else
|
||||
$title = $page['language']['title'] . ' ● ' . $settings['firm_name'];
|
||||
|
||||
$meta_keywords = $page['language']['meta_keywords'];
|
||||
$meta_description = $page['language']['meta_description'];
|
||||
}
|
||||
|
||||
$seo_additional = \front\factory\SeoAdditional::seo_active();
|
||||
if (is_array($seo_additional) and count($seo_additional)) foreach ($seo_additional as $seo)
|
||||
{
|
||||
preg_match('/' . str_replace('/', '\/', $seo['url']) . '/', $_SERVER['REQUEST_URI'], $seo_results);
|
||||
if (is_array($seo_results) and count($seo_results))
|
||||
{
|
||||
if ($seo['title'])
|
||||
$title = $seo['title'];
|
||||
|
||||
if ($seo['keywords'])
|
||||
$meta_keywords = $seo['keywords'];
|
||||
|
||||
if ($meta_description)
|
||||
$meta_description = $seo['description'];
|
||||
|
||||
if ($seo['text'])
|
||||
$html = str_replace('[DODATKOWA_TRESC]', '<div class="seo-additional-text">' . $seo['text'] . '</div>', $html);
|
||||
else
|
||||
$html = str_replace('[DODATKOWA_TRESC]', '', $html);
|
||||
}
|
||||
}
|
||||
|
||||
$html = str_replace('[DODATKOWA_TRESC]', '', $html);
|
||||
$html = str_replace('[TITLE]', $title, $html);
|
||||
$html = str_replace('[META_KEYWORDS]', $meta_keywords, $html);
|
||||
$html = str_replace('[META_DESCRIPTION]', $meta_description, $html);
|
||||
$html = str_replace('[OG_URL]', $domain_prefix . '://' . $www . $url . $_SERVER["REQUEST_URI"], $html);
|
||||
$html = str_replace('[OG_IMG]', $og_image ? ($domain_prefix . '://' . $www . $url . '/' . $og_image) : '', $html);
|
||||
$html = str_replace('[JEZYKI]', \front\view\Languages::languages(), $html);
|
||||
$html = str_replace('[KALENDARZ]', \front\view\Site::calendar(), $html);
|
||||
$html = str_replace('[TYTUL_STRONY]', \front\view\Site::title(
|
||||
$page['language']['title'],
|
||||
$page['show_title'],
|
||||
$page['language']['site_title']
|
||||
), $html);
|
||||
$html = str_replace('[STRONA_GLOWNA]', \front\factory\Pages::lang_url(
|
||||
\front\factory\Pages::main_page_id(),
|
||||
$lang_id,
|
||||
\S::get_domain($_SERVER['HTTP_HOST']),
|
||||
\front\factory\Languages::default_domain()
|
||||
), $html);
|
||||
|
||||
preg_match_all(self::article_pattern, $html, $articles_list);
|
||||
if (is_array($articles_list[0])) foreach ($articles_list[0] as $article_tmp)
|
||||
{
|
||||
$article_tmp = explode(':', $article_tmp);
|
||||
$html = str_replace('[ARTYKUL:' . $article_tmp[1] . ']', \front\view\Articles::article_full($article_tmp[1], $lang_id), $html);
|
||||
}
|
||||
|
||||
/* atrybut noindex */
|
||||
if (\S::get('article'))
|
||||
{
|
||||
\front\factory\Articles::article_noindex(\S::get('article')) === '1' ? $noindex = 'noindex' : $noindex = 'index, follow';
|
||||
$html = str_replace('[META_INDEX]', '<meta name="robots" content="' . $noindex . '">', $html);
|
||||
}
|
||||
else
|
||||
{
|
||||
$page['language']['noindex'] === '1' ? $noindex = 'noindex' : $noindex = 'index, follow';
|
||||
$html = str_replace('[META_INDEX]', '<meta name="robots" content="' . $noindex . '">', $html);
|
||||
}
|
||||
|
||||
if ($page['language']['canonical'])
|
||||
$html = str_replace('</head>', '<link rel="canonical" href="' . $page['language']['canonical'] . '" /></head>', $html);
|
||||
|
||||
while (strpos($html, '[PHP]') !== false)
|
||||
{
|
||||
$text = explode('[PHP]', $html);
|
||||
$before = $text[0];
|
||||
for ($i = 1; $i < count($text); $i++)
|
||||
{
|
||||
$temp = explode('[/PHP]', $text[$i]);
|
||||
$code = $temp[0];
|
||||
|
||||
ob_start();
|
||||
eval(str_replace(''', '"', $code));
|
||||
$out .= ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
$out .= $temp[1];
|
||||
}
|
||||
$html = $before . $out;
|
||||
}
|
||||
|
||||
preg_match_all(self::maps_pattern, $html, $maps_list);
|
||||
if (is_array($maps_list[1]) and !empty($maps_list[1]))
|
||||
{
|
||||
$html = strrev(implode(strrev('<link class="footer" rel="stylesheet" type="text/css" href="/libraries/leaflet/leaflet.css"><script class="footer" type="text/javascript" src="/libraries/leaflet/leaflet.js"></script></head>'), explode(strrev('</head>'), strrev($html), 2)));
|
||||
foreach ($maps_list[1] as $map_tmp)
|
||||
{
|
||||
++$map_counter;
|
||||
$map_settings = explode('|', $map_tmp);
|
||||
$html = str_replace('[MAPA]' . $map_tmp . '[/MAPA]', \front\view\Articles::map($map_settings, $map_counter), $html);
|
||||
}
|
||||
}
|
||||
|
||||
$html = str_replace('[ALERT]', \front\view\Site::alert(), $html);
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
public static function widget_phone()
|
||||
{
|
||||
$tpl = new \Tpl;
|
||||
return $tpl->render('widgets/widget-phone');
|
||||
}
|
||||
|
||||
public static function facebook($facebook_link)
|
||||
{
|
||||
$tpl = new \Tpl;
|
||||
$tpl->facebook_link = $facebook_link;
|
||||
return $tpl->render('site/facebook');
|
||||
}
|
||||
|
||||
public static function title($title, $show_title, $site_title)
|
||||
{
|
||||
if (!$show_title)
|
||||
return false;
|
||||
|
||||
if ($site_title)
|
||||
$title = $site_title;
|
||||
|
||||
$tpl = new \Tpl;
|
||||
$tpl->title = $title;
|
||||
return $tpl->render('site/title');
|
||||
}
|
||||
|
||||
static public function alert()
|
||||
{
|
||||
if ($alert = \S::get_session('alert'))
|
||||
{
|
||||
\S::delete_session('alert');
|
||||
\S::delete_session('alert-class');
|
||||
|
||||
return \Tpl::view('site/alert', [
|
||||
'alert' => $alert,
|
||||
'alert_class' => \S::get_session('alert-class')
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public static function copyright()
|
||||
{
|
||||
$tpl = new \Tpl;
|
||||
return $tpl->render('site/copyright');
|
||||
}
|
||||
|
||||
public static function contact()
|
||||
{
|
||||
$tpl = new \Tpl;
|
||||
return $tpl->render('site/contact');
|
||||
}
|
||||
|
||||
public static function cookie_information()
|
||||
{
|
||||
$tpl = new \Tpl;
|
||||
return $tpl->render('site/cookie-information');
|
||||
}
|
||||
|
||||
public static function calendar($month = '', $year = '', $ajax = false)
|
||||
{
|
||||
global $settings, $lang_id;
|
||||
|
||||
if (!$settings['calendar'])
|
||||
return false;
|
||||
|
||||
if (!$month) $month = date('n');
|
||||
if (!$year) $year = date('Y');
|
||||
|
||||
$tpl = new \Tpl;
|
||||
$tpl->month = $month;
|
||||
$tpl->year = $year;
|
||||
$tpl->months = \S::months();
|
||||
$tpl->ajax = $ajax;
|
||||
$tpl->articles = \front\factory\Articles::articles_by_date($month, $year, $lang_id);
|
||||
return $tpl->render('site/calendar');
|
||||
}
|
||||
|
||||
public static function visit_counter($visit_counter)
|
||||
{
|
||||
$tpl = new \Tpl;
|
||||
$tpl->visit_counter = $visit_counter;
|
||||
return $tpl->render('site/visit-counter');
|
||||
}
|
||||
|
||||
public static function contrast()
|
||||
{
|
||||
$tpl = new \Tpl;
|
||||
return $tpl->render('site/contrast');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user