Dodaj funkcje do czyszczenia tekstu ogłoszeń oraz aktualizuj wywołania w szablonach
This commit is contained in:
@@ -1,6 +1,68 @@
|
|||||||
<?php
|
<?php
|
||||||
class S
|
class S
|
||||||
{
|
{
|
||||||
|
static public function strip_attributes_except_style($html) {
|
||||||
|
return preg_replace_callback(
|
||||||
|
'/<([a-z0-9]+)([^>]*)>/i',
|
||||||
|
function ($matches) {
|
||||||
|
$tag = $matches[1];
|
||||||
|
$attrs = $matches[2];
|
||||||
|
|
||||||
|
// Znajdź tylko atrybut "style"
|
||||||
|
preg_match('/\sstyle\s*=\s*("[^"]*"|\'[^\']*\'|[^"\'>\s]+)/i', $attrs, $styleMatch);
|
||||||
|
$style = isset($styleMatch[0]) ? ' ' . $styleMatch[0] : '';
|
||||||
|
|
||||||
|
return "<$tag$style>";
|
||||||
|
},
|
||||||
|
$html
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static public function strip_attributes_except_style_and_clean_font($html) {
|
||||||
|
return preg_replace_callback(
|
||||||
|
'/<([a-z0-9]+)([^>]*)>/i',
|
||||||
|
function ($matches) {
|
||||||
|
$tag = $matches[1];
|
||||||
|
$attrs = $matches[2];
|
||||||
|
|
||||||
|
// Wyciągnij styl
|
||||||
|
preg_match('/\sstyle\s*=\s*("[^"]*"|\'[^\']*\'|[^"\'>\s]+)/i', $attrs, $styleMatch);
|
||||||
|
$style = '';
|
||||||
|
|
||||||
|
if (isset($styleMatch[1])) {
|
||||||
|
$rawStyle = trim($styleMatch[1], '\'"'); // bez cudzysłowów
|
||||||
|
|
||||||
|
// usuń font-family (również z fallbackami np. Arial, sans-serif)
|
||||||
|
$filtered = [];
|
||||||
|
foreach (explode(';', $rawStyle) as $rule) {
|
||||||
|
if (stripos(trim($rule), 'font-family') !== 0) {
|
||||||
|
$filtered[] = trim($rule);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($filtered)) {
|
||||||
|
$style = ' style="' . implode('; ', $filtered) . '"';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return "<$tag$style>";
|
||||||
|
},
|
||||||
|
$html
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static public function clear_advert_text( $text )
|
||||||
|
{
|
||||||
|
$text = preg_replace('#<style[^>]*>.*?</style>#is', '', $text);
|
||||||
|
$text = preg_replace('#<script[^>]*>.*?</script>#is', '', $text);
|
||||||
|
$text = preg_replace('/on\w+="[^"]*"/i', '', $text);
|
||||||
|
$text = preg_replace("/on\w+='[^']*'/i", '', $text);
|
||||||
|
$text = preg_replace('/(href|src)\s*=\s*["\']\s*javascript:[^"\']*["\']/i', '', $text);
|
||||||
|
$text = self::strip_attributes_except_style($text);
|
||||||
|
$text = self::strip_attributes_except_style_and_clean_font($text);
|
||||||
|
return $text;
|
||||||
|
}
|
||||||
|
|
||||||
static public function strpos_arr( $haystack, $needle )
|
static public function strpos_arr( $haystack, $needle )
|
||||||
{
|
{
|
||||||
if (!is_array($needle)) $needle = array($needle);
|
if (!is_array($needle)) $needle = array($needle);
|
||||||
|
|||||||
@@ -1067,7 +1067,7 @@ class GlobelusFirms
|
|||||||
'id_position' => $id_position ? $id_position : null,
|
'id_position' => $id_position ? $id_position : null,
|
||||||
'city' => $values['city'],
|
'city' => $values['city'],
|
||||||
'region' => $values['region'],
|
'region' => $values['region'],
|
||||||
'text' => $values['text'],
|
'text' => \S::clear_advert_text( $values['text'] ),
|
||||||
'contact_person' => $values['contact_person'],
|
'contact_person' => $values['contact_person'],
|
||||||
'email' => $values['email'],
|
'email' => $values['email'],
|
||||||
'phone' => $values['phone'],
|
'phone' => $values['phone'],
|
||||||
@@ -1104,7 +1104,7 @@ class GlobelusFirms
|
|||||||
'id_position' => $id_position ? $id_position : null,
|
'id_position' => $id_position ? $id_position : null,
|
||||||
'city' => $values['city'],
|
'city' => $values['city'],
|
||||||
'region' => $values['region'],
|
'region' => $values['region'],
|
||||||
'text' => $values['text'],
|
'text' => \S::clear_advert_text( $values['text'] ),
|
||||||
'contact_person' => $values['contact_person'],
|
'contact_person' => $values['contact_person'],
|
||||||
'email' => $values['email'],
|
'email' => $values['email'],
|
||||||
'phone' => $values['phone'],
|
'phone' => $values['phone'],
|
||||||
|
|||||||
@@ -169,7 +169,7 @@
|
|||||||
?>
|
?>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<?
|
<?
|
||||||
$text = $this->advert['text'];
|
$text = $this -> advert['text'];
|
||||||
if (!$this->g_user) :
|
if (!$this->g_user) :
|
||||||
$text = preg_replace('/[a-z0-9_\-\+\.]+@[a-z0-9\-]+\.([a-z]{2,4})(?:\.[a-z]{2})?/i', ' <a href="/logowanie">Zaloguj się aby zobaczyć adres email</a> ', $text);
|
$text = preg_replace('/[a-z0-9_\-\+\.]+@[a-z0-9\-]+\.([a-z]{2,4})(?:\.[a-z]{2})?/i', ' <a href="/logowanie">Zaloguj się aby zobaczyć adres email</a> ', $text);
|
||||||
$text = preg_replace(
|
$text = preg_replace(
|
||||||
@@ -178,6 +178,7 @@
|
|||||||
$text
|
$text
|
||||||
);
|
);
|
||||||
endif;
|
endif;
|
||||||
|
$text = \S::clear_advert_text( $text );
|
||||||
echo $text;
|
echo $text;
|
||||||
?>
|
?>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -40,9 +40,9 @@
|
|||||||
<? endif;?>
|
<? endif;?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-12 col-sm-11 col-md-10">
|
<div class="col-12 col-sm-11 col-md-10">
|
||||||
<div class="short-text">
|
<div class="short-text">
|
||||||
<?= mb_substr( strip_tags( $advert['text'] ), 0, 100, 'UTF-8' );?>...
|
<?= mb_substr( strip_tags( \S::clear_advert_text( $advert['text'] ) ), 0, 100, 'UTF-8' );?>...
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -42,7 +42,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="col-12 col-sm-11 col-md-10">
|
<div class="col-12 col-sm-11 col-md-10">
|
||||||
<div class="short-text">
|
<div class="short-text">
|
||||||
<?= mb_substr( strip_tags( $advert['text'] ), 0, 100, 'UTF-8' );?>...
|
<?= mb_substr( strip_tags( \S::clear_advert_text( $advert['text'] ) ), 0, 100, 'UTF-8' );?>...
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -55,7 +55,7 @@
|
|||||||
<span class="place"><?= $advert['country'];?> - <?= $advert['city'];?></span> | <span class="firm"><?= $advert['firm_name_profile'];?></span> | <span class="category"><?= $advert['category'];?></span>
|
<span class="place"><?= $advert['country'];?> - <?= $advert['city'];?></span> | <span class="firm"><?= $advert['firm_name_profile'];?></span> | <span class="category"><?= $advert['category'];?></span>
|
||||||
</div>
|
</div>
|
||||||
<div class="short-text">
|
<div class="short-text">
|
||||||
<?= mb_substr( strip_tags( $advert['text'] ), 0, 150, 'UTF-8' );?>...
|
<?= mb_substr( strip_tags( \S::clear_advert_text( $advert['text'] ) ), 0, 150, 'UTF-8' );?>...
|
||||||
</div>
|
</div>
|
||||||
<a href="/oferta/<?= $advert['id'];?>/<?= \S::seo( $advert['title'], true );?>" target="_blank" class="btn btn-success"><?= $lang['szczegoly-oferty'];?></a>
|
<a href="/oferta/<?= $advert['id'];?>/<?= \S::seo( $advert['title'], true );?>" target="_blank" class="btn btn-success"><?= $lang['szczegoly-oferty'];?></a>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -143,7 +143,7 @@
|
|||||||
<?= $cv['sex'] ? $lang['ostatnio-szukal-pracy'] : $lang['ostatnio-szukala-pracy'];?>: <strong><?= $cv['last_refresh'] ? date( 'Y-m-d', strtotime( $cv['last_refresh'] ) ) : date( 'Y-m-d', strtotime( $cv['register_date'] ) );?></strong>
|
<?= $cv['sex'] ? $lang['ostatnio-szukal-pracy'] : $lang['ostatnio-szukala-pracy'];?>: <strong><?= $cv['last_refresh'] ? date( 'Y-m-d', strtotime( $cv['last_refresh'] ) ) : date( 'Y-m-d', strtotime( $cv['register_date'] ) );?></strong>
|
||||||
</div>
|
</div>
|
||||||
<div class="short-text">
|
<div class="short-text">
|
||||||
<?= $advert['short_text'];?>
|
<?= \S::clear_advert_text( $advert['short_text'] );?>
|
||||||
</div>
|
</div>
|
||||||
<a href="/kandydat/<?= $cv['id'];?>/<?= \S::seo( $cv['surname'] . ' ' . $cv['name'], true );?>/" class="btn btn-success"><?= $lang['profil-kandydata'];?></a>
|
<a href="/kandydat/<?= $cv['id'];?>/<?= \S::seo( $cv['surname'] . ' ' . $cv['name'], true );?>/" class="btn btn-success"><?= $lang['profil-kandydata'];?></a>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -182,7 +182,7 @@
|
|||||||
<a href="/oferty-pracy/<?= \S::seo( $advert['country'], true );?>" class="place" title="praca <?= $adver['country'];?>"><?= $advert['country'];?></a> - <?= $advert['city'];?></span> | <a href="/pracodawca/<?= $advert['user_id'];?>/<?= \S::seo( $advert['firm_name_profile'] );?>" class="firm"><?= $advert['firm_name_profile'];?></a> | <a href="/oferty-pracy/<?= \S::seo( $advert['category'], true );?>" class="category" title="praca <?= $advert['category'];?>"><?= $advert['category'];?></a>
|
<a href="/oferty-pracy/<?= \S::seo( $advert['country'], true );?>" class="place" title="praca <?= $adver['country'];?>"><?= $advert['country'];?></a> - <?= $advert['city'];?></span> | <a href="/pracodawca/<?= $advert['user_id'];?>/<?= \S::seo( $advert['firm_name_profile'] );?>" class="firm"><?= $advert['firm_name_profile'];?></a> | <a href="/oferty-pracy/<?= \S::seo( $advert['category'], true );?>" class="category" title="praca <?= $advert['category'];?>"><?= $advert['category'];?></a>
|
||||||
</div>
|
</div>
|
||||||
<div class="short-text">
|
<div class="short-text">
|
||||||
<?= mb_substr( strip_tags( $advert['text'] ), 0, 150, 'UTF-8' );?>...
|
<?= mb_substr( strip_tags( \S::clear_advert_text( $advert['text'] ) ), 0, 150, 'UTF-8' );?>...
|
||||||
</div>
|
</div>
|
||||||
<a href="/oferta/<?= $advert['id'];?>/<?= \S::seo( $advert['title'], true );?>" class="btn btn-success"><?= $lang['szczegoly-oferty'];?></a>
|
<a href="/oferta/<?= $advert['id'];?>/<?= \S::seo( $advert['title'], true );?>" class="btn btn-success"><?= $lang['szczegoly-oferty'];?></a>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -43,7 +43,7 @@
|
|||||||
<?= $lang['tel.'];?> <?= $candidate['phone'];?> | <?= $lang['email'];?>: <a href="mailto:<?= $candidate['email'];?>"><?= $candidate['email'];?></a>
|
<?= $lang['tel.'];?> <?= $candidate['phone'];?> | <?= $lang['email'];?>: <a href="mailto:<?= $candidate['email'];?>"><?= $candidate['email'];?></a>
|
||||||
</div>
|
</div>
|
||||||
<div class="short-text">
|
<div class="short-text">
|
||||||
<?= $advert['short_text'];?>
|
<?= \S::clear_advert_text( $advert['short_text'] );?>
|
||||||
</div>
|
</div>
|
||||||
<a href="/kandydat/<?= $candidate['id'];?>/<?= \S::seo( $candidate['surname'] . ' ' . $candidate['name'], true );?>/" target="_blank" class="btn btn-success"><?= $lang['profil-kandydata'];?></a>
|
<a href="/kandydat/<?= $candidate['id'];?>/<?= \S::seo( $candidate['surname'] . ' ' . $candidate['name'], true );?>/" target="_blank" class="btn btn-success"><?= $lang['profil-kandydata'];?></a>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -69,7 +69,7 @@
|
|||||||
<?= $candidate['sex'] ? $lang['ostatnio-szukal-pracy'] : $lang['ostatnio-szukala-pracy'];?>: <strong><?= $candidate['last_refresh'] ? date( 'Y-m-d', strtotime( $candidate['last_refresh'] ) ) : date( 'Y-m-d', strtotime( $candidate['register_date'] ) );?></strong>
|
<?= $candidate['sex'] ? $lang['ostatnio-szukal-pracy'] : $lang['ostatnio-szukala-pracy'];?>: <strong><?= $candidate['last_refresh'] ? date( 'Y-m-d', strtotime( $candidate['last_refresh'] ) ) : date( 'Y-m-d', strtotime( $candidate['register_date'] ) );?></strong>
|
||||||
</div>
|
</div>
|
||||||
<div class="short-text">
|
<div class="short-text">
|
||||||
<?= $advert['short_text'];?>
|
<?= \S::clear_advert_text( $advert['short_text'] );?>
|
||||||
</div>
|
</div>
|
||||||
<a href="/proponowany-kandydat/<?= $candidate['id'];?>/<?= \S::seo( $candidate['surname'] . ' ' . $candidate['name'], true );?>/" class="btn btn-success" target="_blank"><?= $lang['profil-kandydata'];?></a>
|
<a href="/proponowany-kandydat/<?= $candidate['id'];?>/<?= \S::seo( $candidate['surname'] . ' ' . $candidate['name'], true );?>/" class="btn btn-success" target="_blank"><?= $lang['profil-kandydata'];?></a>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user