first commit
This commit is contained in:
357
autoload/front/factory/class.Articles.php
Normal file
357
autoload/front/factory/class.Articles.php
Normal file
@@ -0,0 +1,357 @@
|
||||
<?php
|
||||
namespace front\factory;
|
||||
class Articles
|
||||
{
|
||||
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 ( !$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' ] ] );
|
||||
$article['files'] = $mdb -> select( 'pp_articles_files', '*', [ 'article_id' => (int)$article_id ] );
|
||||
$article['pages'] = $mdb -> select( 'pp_articles_pages', 'page_id', [ 'article_id' => (int)$article_id ] );
|
||||
$article['tags'] = $mdb -> select( 'pp_tags', [ '[><]pp_articles_tags' => [ 'id' => 'tag_id' ] ], 'name', [ 'article_id' => (int)$article_id ] );
|
||||
$results = $mdb -> select( 'pp_articles_additional_params', [ '[><]pp_articles_additional_values' => [ 'id' => 'param_id' ] ], [ 'name', 'value', 'language_id' ], [ 'article_id' => (int)$article_id ] );
|
||||
if ( is_array( $results ) ) foreach ( $results as $row )
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
431
autoload/front/factory/class.AuditSEO.php
Normal file
431
autoload/front/factory/class.AuditSEO.php
Normal file
@@ -0,0 +1,431 @@
|
||||
<?php
|
||||
namespace front\factory;
|
||||
class AuditSEO
|
||||
{
|
||||
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 data05( $url )
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
$data04 = $mdb -> get( 'as_sites', [
|
||||
'effective_url',
|
||||
'page_speed_insight_mobile'
|
||||
], [
|
||||
'url' => $url
|
||||
] );
|
||||
|
||||
if ( !$data04['page_speed_insight_mobile'] )
|
||||
{
|
||||
$ch = curl_init();
|
||||
curl_setopt( $ch, CURLOPT_URL, 'https://www.googleapis.com/pagespeedonline/v5/runPagespeed?url=' . $data04['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 ] );
|
||||
|
||||
$data04['page_speed_insight_mobile'] = json_decode( $response, true );
|
||||
}
|
||||
else
|
||||
{
|
||||
$data04['page_speed_insight_mobile'] = json_decode( $data04['page_speed_insight_mobile'], true );
|
||||
}
|
||||
return $data04;
|
||||
}
|
||||
|
||||
public static function data04( $url )
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
$data04 = $mdb -> get( 'as_sites', [
|
||||
'effective_url',
|
||||
'page_speed_insight_desktop'
|
||||
], [
|
||||
'url' => $url
|
||||
] );
|
||||
|
||||
if ( !$data04['page_speed_insight_desktop'] )
|
||||
{
|
||||
$ch = curl_init();
|
||||
curl_setopt( $ch, CURLOPT_URL, 'https://www.googleapis.com/pagespeedonline/v5/runPagespeed?url=' . $data04['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 ] );
|
||||
|
||||
$data04['page_speed_insight_desktop'] = json_decode( $response, true );
|
||||
}
|
||||
else
|
||||
{
|
||||
$data04['page_speed_insight_desktop'] = json_decode( $data04['page_speed_insight_desktop'], true );
|
||||
}
|
||||
return $data04;
|
||||
}
|
||||
|
||||
public static function data03( $url )
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
$data03 = $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['code_to_text_ratio'] = round( ( $data03['text_length'] / ( $data03['text_length'] + $data03['code_length'] ) * 100 ), 0 ) . '%';
|
||||
|
||||
return $data03;
|
||||
}
|
||||
|
||||
public static function data02( $url )
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
$data02 = $mdb -> get( 'as_sites', [
|
||||
'meta_robots',
|
||||
'robots_txt',
|
||||
'redirect_www',
|
||||
'https'
|
||||
], [
|
||||
'url' => $url
|
||||
] );
|
||||
|
||||
$data02['robots_txt'] = self::robots_allowed( $data02['robots_txt'], 'GoogleBot' ) ? 'tak' : 'nie';
|
||||
$data02['redirect_www'] = $data02['redirect_www'] ? 'tak' : 'nie';
|
||||
$data02['https'] = $data02['https'] ? 'tak' : 'nie';
|
||||
|
||||
return $data02;
|
||||
}
|
||||
|
||||
public static function data01( $url )
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
$data01 = $mdb -> get( 'as_sites', [
|
||||
'effective_url',
|
||||
'ip',
|
||||
'location',
|
||||
'favicon',
|
||||
'cms'
|
||||
], [
|
||||
'url' => $url
|
||||
] );
|
||||
|
||||
$location = json_decode( $data01['location'] );
|
||||
$data01['location'] = $location -> country;
|
||||
$data01['favicon'] = $data01['favicon'] != null ? 'tak' : 'nie';
|
||||
|
||||
return $data01;
|
||||
}
|
||||
|
||||
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 = '';
|
||||
|
||||
for ( $i = 0; $i < $metas -> length; $i++ )
|
||||
{
|
||||
$meta = $metas -> item( $i );
|
||||
$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 audit( $url )
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
if ( !$url )
|
||||
return false;
|
||||
|
||||
if ( strpos( 'http://', $url ) === false and strpos( 'https://', $url ) === false )
|
||||
$url = 'http://' . $url;
|
||||
|
||||
$url_tmp = parse_url( $url );
|
||||
$url = strip_tags( $url_tmp['host'] );
|
||||
|
||||
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' );
|
||||
|
||||
$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 );
|
||||
curl_close ( $ch );
|
||||
|
||||
$url_parse = parse_url( $effective_url );
|
||||
$url_tmp = $url_parse['host'];
|
||||
$redirect_www = false;
|
||||
|
||||
if ( strpos( $url_tmp, $url_parse['scheme'] . '://www.' ) === 0 )
|
||||
{
|
||||
$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
|
||||
] );
|
||||
|
||||
return $url;
|
||||
}
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
405
autoload/front/factory/class.Globelus.php
Normal file
405
autoload/front/factory/class.Globelus.php
Normal file
@@ -0,0 +1,405 @@
|
||||
<?php
|
||||
namespace front\factory;
|
||||
class Globelus
|
||||
{
|
||||
function gen_password( $length = 10 )
|
||||
{
|
||||
$chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
||||
return substr( str_shuffle( $chars ), 0, $length );
|
||||
}
|
||||
|
||||
static public function position_name( $id_position )
|
||||
{
|
||||
global $mdb;
|
||||
if ( !$name = \Cache::fetch( "position_name:$id_position" ) )
|
||||
{
|
||||
$name = $mdb -> get( 'globelus_positions', 'name', [ 'id' => $id_position ] );
|
||||
\Cache::store( "position_name:$id_position", $name );
|
||||
}
|
||||
return $name;
|
||||
}
|
||||
|
||||
static public function get_country_name( $id_country )
|
||||
{
|
||||
global $mdb;
|
||||
if ( !$name = \Cache::fetch( "country_name:$id_country" ) )
|
||||
{
|
||||
$name = $mdb -> get( 'globelus_countries', 'name', [ 'id' => $id_country ] );
|
||||
\Cache::store( "country_name:$id_country", $name );
|
||||
}
|
||||
return $name;
|
||||
}
|
||||
|
||||
static public function get_category_name( $id_category )
|
||||
{
|
||||
global $mdb;
|
||||
if ( !$name = \Cache::fetch( "category_name:$id_category" ) )
|
||||
{
|
||||
$name = $mdb -> get( 'globelus_adverts_categories', 'name', [ 'id' => $id_category ] );
|
||||
\Cache::store( "category_name:$id_category", $name );
|
||||
}
|
||||
return $name;
|
||||
}
|
||||
|
||||
static public function get_positions_list()
|
||||
{
|
||||
global $mdb;
|
||||
return $mdb -> select( 'globelus_positions', '*', [ 'ORDER' => [ 'name' => 'ASC' ] ] );
|
||||
}
|
||||
|
||||
static public function get_voivodeship_seo( $id_voivodship )
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
if ( !$name = \Cache::fetch( "get_voivodeship_seo:$id_voivodship" ) )
|
||||
{
|
||||
$name = $mdb -> get( 'globelus_voivodeships', 'name_seo', [ 'id' => $id_voivodship ] );
|
||||
|
||||
\Cache::store( "get_voivodeship_seo:$id_voivodship", $name );
|
||||
}
|
||||
|
||||
return $name;
|
||||
}
|
||||
|
||||
static public function get_voivodeship_name( $id_voivodship )
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
if ( !$name = \Cache::fetch( "get_voivodeship_name:$id_voivodship" ) )
|
||||
{
|
||||
$name = $mdb -> get( 'globelus_voivodeships', 'name', [ 'id' => $id_voivodship ] );
|
||||
|
||||
\Cache::store( "get_voivodeship_name:$id_voivodship", $name );
|
||||
}
|
||||
|
||||
return $name;
|
||||
}
|
||||
|
||||
static public function get_voivodeships_list()
|
||||
{
|
||||
global $mdb;
|
||||
return $mdb -> select( 'globelus_voivodeships', '*', [ 'ORDER' => [ 'id' => 'ASC' ] ] );
|
||||
}
|
||||
|
||||
public static function clean_text( $text )
|
||||
{
|
||||
// $text = preg_replace('/(<[^>]*) style=("[^"]+"|\'[^\']+\')([^>]*>)/i', '$1$3', $text );
|
||||
$text = preg_replace('/(<[^>]*) class=("[^"]+"|\'[^\']+\')([^>]*>)/i', '$1$3', $text );
|
||||
$text = preg_replace('/(<[^>]*) id=("[^"]+"|\'[^\']+\')([^>]*>)/i', '$1$3', $text );
|
||||
// $text = preg_replace('/[a-z0-9_\-\+\.]+@[a-z0-9\-]+\.([a-z]{2,4})(?:\.[a-z]{2})?/i', '[email usunięty]', $text );
|
||||
return $text;
|
||||
}
|
||||
|
||||
public static function work_types()
|
||||
{
|
||||
return [
|
||||
// 1 => \S::lang( 'praca-stala' ),
|
||||
// 2 => \S::lang( 'praca-tymczasowa' ),
|
||||
// 3 => \S::lang( 'praca-sezonowa' ),
|
||||
// 4 => \S::lang( 'praktyka/staz' ),
|
||||
// 5 => \S::lang( 'inna' ),
|
||||
6 => 'praca na czas nieokreślony',
|
||||
7 => 'praca na czas określony/tymczasowa',
|
||||
8 => 'staż/praktyka',
|
||||
9 => 'B2B',
|
||||
10 => 'umowa agencyjna',
|
||||
11 => 'praca zdalna',
|
||||
];
|
||||
}
|
||||
|
||||
public static function category_id_by_nameseo( $name_seo )
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
if ( !$id = \Cache::fetch( "category_id_by_nameseo:$name_seo" ) )
|
||||
{
|
||||
$id = $mdb -> get( 'globelus_adverts_categories', 'id', [ 'name_seo' => $name_seo ] );
|
||||
|
||||
\Cache::store( "category_id_by_nameseo:$name_seo", $id );
|
||||
}
|
||||
|
||||
return $id;
|
||||
}
|
||||
|
||||
public static function country_id_by_nameseo( $name_seo )
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
if ( !$id = \Cache::fetch( "country_id_by_nameseo:$name_seo" ) )
|
||||
{
|
||||
$id = $mdb -> get( 'globelus_countries', 'id', [ 'name_seo' => $name_seo ] );
|
||||
|
||||
\Cache::store( "country_id_by_nameseo:$name_seo", $id );
|
||||
}
|
||||
|
||||
return $id;
|
||||
}
|
||||
|
||||
public static function country_name( $country_id )
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
if ( !$name = \Cache::fetch( "country_name:$country_id" ) )
|
||||
{
|
||||
$name = $mdb -> get( 'globelus_countries', 'name', [ 'id' => $country_id ] );
|
||||
|
||||
\Cache::store( "country_name:$country_id", $name );
|
||||
}
|
||||
|
||||
return $name;
|
||||
}
|
||||
|
||||
public static function category_name( $category_id )
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
if ( !$name = \Cache::fetch( "category_name:$category_id" ) )
|
||||
{
|
||||
$name = $mdb -> get( 'globelus_adverts_categories', 'name', [ 'id' => $category_id ] );
|
||||
|
||||
\Cache::store( "category_name:$category_id", $name );
|
||||
}
|
||||
|
||||
return $name;
|
||||
}
|
||||
|
||||
public static function validate_date( $date )
|
||||
{
|
||||
$date = \DateTime::createFromFormat( 'Y-m-d', $date );
|
||||
$date_errors = \DateTime::getLastErrors();
|
||||
if ( $date_errors['warning_count'] + $date_errors['error_count'] > 0 )
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function noPL( $val )
|
||||
{
|
||||
$table = Array(
|
||||
"\xc4\x85" => "a", "\xc4\x84" => "A", "\xc4\x87" => "c", "\xc4\x86" => "C",
|
||||
"\xc4\x99" => "e", "\xc4\x98" => "E", "\xc5\x82" => "l", "\xc5\x81" => "L",
|
||||
"\xc3\xb3" => "o", "\xc3\x93" => "O", "\xc5\x9b" => "s", "\xc5\x9a" => "S",
|
||||
"\xc5\xbc" => "z", "\xc5\xbb" => "Z", "\xc5\xba" => "z", "\xc5\xb9" => "Z",
|
||||
"\xc5\x84" => "n", "\xc5\x83" => "N", '&' => 'and', '@' => 'at',
|
||||
'©' => 'c', '®' => 'r', 'À' => 'a',
|
||||
'Á' => 'a', 'Â' => 'a', 'Ä' => 'a', 'Å' => 'a', 'Æ' => 'ae','Ç' => 'c',
|
||||
'È' => 'e', 'É' => 'e', 'Ë' => 'e', 'Ì' => 'i', 'Í' => 'i', 'Î' => 'i',
|
||||
'Ï' => 'i', 'Ò' => 'o', 'Ó' => 'o', 'Ô' => 'o', 'Õ' => 'o', 'Ö' => 'o',
|
||||
'Ø' => 'o', 'Ù' => 'u', 'Ú' => 'u', 'Û' => 'u', 'Ü' => 'u', 'Ý' => 'y',
|
||||
'ß' => 'ss','à' => 'a', 'á' => 'a', 'â' => 'a', 'ä' => 'a', 'å' => 'a',
|
||||
'æ' => 'ae','ç' => 'c', 'è' => 'e', 'é' => 'e', 'ê' => 'e', 'ë' => 'e',
|
||||
'ì' => 'i', 'í' => 'i', 'î' => 'i', 'ï' => 'i', 'ò' => 'o', 'ó' => 'o',
|
||||
'ô' => 'o', 'õ' => 'o', 'ö' => 'o', 'ø' => 'o', 'ù' => 'u', 'ú' => 'u',
|
||||
'û' => 'u', 'ü' => 'u', 'ý' => 'y', 'þ' => 'p', 'ÿ' => 'y', 'Ā' => 'a',
|
||||
'ā' => 'a', 'Ă' => 'a', 'ă' => 'a', 'Ą' => 'a', 'ą' => 'a', 'Ć' => 'c',
|
||||
'ć' => 'c', 'Ĉ' => 'c', 'ĉ' => 'c', 'Ċ' => 'c', 'ċ' => 'c', 'Č' => 'c',
|
||||
'č' => 'c', 'Ď' => 'd', 'ď' => 'd', 'Đ' => 'd', 'đ' => 'd', 'Ē' => 'e',
|
||||
'ē' => 'e', 'Ĕ' => 'e', 'ĕ' => 'e', 'Ė' => 'e', 'ė' => 'e', 'Ę' => 'e',
|
||||
'ę' => 'e', 'Ě' => 'e', 'ě' => 'e', 'Ĝ' => 'g', 'ĝ' => 'g', 'Ğ' => 'g',
|
||||
'ğ' => 'g', 'Ġ' => 'g', 'ġ' => 'g', 'Ģ' => 'g', 'ģ' => 'g', 'Ĥ' => 'h',
|
||||
'ĥ' => 'h', 'Ħ' => 'h', 'ħ' => 'h', 'Ĩ' => 'i', 'ĩ' => 'i', 'Ī' => 'i',
|
||||
'ī' => 'i', 'Ĭ' => 'i', 'ĭ' => 'i', 'Į' => 'i', 'į' => 'i', 'İ' => 'i',
|
||||
'ı' => 'i', 'IJ' => 'ij','ij' => 'ij','Ĵ' => 'j', 'ĵ' => 'j', 'Ķ' => 'k',
|
||||
'ķ' => 'k', 'ĸ' => 'k', 'Ĺ' => 'l', 'ĺ' => 'l', 'Ļ' => 'l', 'ļ' => 'l',
|
||||
'Ľ' => 'l', 'ľ' => 'l', 'Ŀ' => 'l', 'ŀ' => 'l', 'Ł' => 'l', 'ł' => 'l',
|
||||
'Ń' => 'n', 'ń' => 'n', 'Ņ' => 'n', 'ņ' => 'n', 'Ň' => 'n', 'ň' => 'n',
|
||||
'ʼn' => 'n', 'Ŋ' => 'n', 'ŋ' => 'n', 'Ō' => 'o', 'ō' => 'o', 'Ŏ' => 'o',
|
||||
'ŏ' => 'o', 'Ő' => 'o', 'ő' => 'o', 'Œ' => 'oe','œ' => 'oe','Ŕ' => 'r',
|
||||
'ŕ' => 'r', 'Ŗ' => 'r', 'ŗ' => 'r', 'Ř' => 'r', 'ř' => 'r', 'Ś' => 's',
|
||||
'ś' => 's', 'Ŝ' => 's', 'ŝ' => 's', 'Ş' => 's', 'ş' => 's', 'Š' => 's',
|
||||
'š' => 's', 'Ţ' => 't', 'ţ' => 't', 'Ť' => 't', 'ť' => 't', 'Ŧ' => 't',
|
||||
'ŧ' => 't', 'Ũ' => 'u', 'ũ' => 'u', 'Ū' => 'u', 'ū' => 'u', 'Ŭ' => 'u',
|
||||
'ŭ' => 'u', 'Ů' => 'u', 'ů' => 'u', 'Ű' => 'u', 'ű' => 'u', 'Ų' => 'u',
|
||||
'ų' => 'u', 'Ŵ' => 'w', 'ŵ' => 'w', 'Ŷ' => 'y', 'ŷ' => 'y', 'Ÿ' => 'y',
|
||||
'Ź' => 'z', 'ź' => 'z', 'Ż' => 'z', 'ż' => 'z', 'Ž' => 'z', 'ž' => 'z',
|
||||
'ſ' => 'z', 'Ə' => 'e', 'ƒ' => 'f', 'Ơ' => 'o', 'ơ' => 'o', 'Ư' => 'u',
|
||||
'ư' => 'u', 'Ǎ' => 'a', 'ǎ' => 'a', 'Ǐ' => 'i', 'ǐ' => 'i', 'Ǒ' => 'o',
|
||||
'ǒ' => 'o', 'Ǔ' => 'u', 'ǔ' => 'u', 'Ǖ' => 'u', 'ǖ' => 'u', 'Ǘ' => 'u',
|
||||
'ǘ' => 'u', 'Ǚ' => 'u', 'ǚ' => 'u', 'Ǜ' => 'u', 'ǜ' => 'u', 'Ǻ' => 'a',
|
||||
'ǻ' => 'a', 'Ǽ' => 'ae','ǽ' => 'ae','Ǿ' => 'o', 'ǿ' => 'o', 'ə' => 'e',
|
||||
'Ё' => 'jo','Є' => 'e', 'І' => 'i', 'Ї' => 'i', 'А' => 'a', 'Б' => 'b',
|
||||
'В' => 'v', 'Г' => 'g', 'Д' => 'd', 'Е' => 'e', 'Ж' => 'zh','З' => 'z',
|
||||
'И' => 'i', 'Й' => 'j', 'К' => 'k', 'Л' => 'l', 'М' => 'm', 'Н' => 'n',
|
||||
'О' => 'o', 'П' => 'p', 'Р' => 'r', 'С' => 's', 'Т' => 't', 'У' => 'u',
|
||||
'Ф' => 'f', 'Х' => 'h', 'Ц' => 'c', 'Ч' => 'ch','Ш' => 'sh','Щ' => 'sch',
|
||||
'Ъ' => '-', 'Ы' => 'y', 'Ь' => '-', 'Э' => 'je','Ю' => 'ju','Я' => 'ja',
|
||||
'а' => 'a', 'б' => 'b', 'в' => 'v', 'г' => 'g', 'д' => 'd', 'е' => 'e',
|
||||
'ж' => 'zh','з' => 'z', 'и' => 'i', 'й' => 'j', 'к' => 'k', 'л' => 'l',
|
||||
'м' => 'm', 'н' => 'n', 'о' => 'o', 'п' => 'p', 'р' => 'r', 'с' => 's',
|
||||
'т' => 't', 'у' => 'u', 'ф' => 'f', 'х' => 'h', 'ц' => 'c', 'ч' => 'ch',
|
||||
'ш' => 'sh','щ' => 'sch','ъ' => '-','ы' => 'y', 'ь' => '-', 'э' => 'je',
|
||||
'ю' => 'ju','я' => 'ja','ё' => 'jo','є' => 'e', 'і' => 'i', 'ї' => 'i',
|
||||
'Ґ' => 'g', 'ґ' => 'g', 'א' => 'a', 'ב' => 'b', 'ג' => 'g', 'ד' => 'd',
|
||||
'ה' => 'h', 'ו' => 'v', 'ז' => 'z', 'ח' => 'h', 'ט' => 't', 'י' => 'i',
|
||||
'ך' => 'k', 'כ' => 'k', 'ל' => 'l', 'ם' => 'm', 'מ' => 'm', 'ן' => 'n',
|
||||
'נ' => 'n', 'ס' => 's', 'ע' => 'e', 'ף' => 'p', 'פ' => 'p', 'ץ' => 'C',
|
||||
'צ' => 'c', 'ק' => 'q', 'ר' => 'r', 'ש' => 'w', 'ת' => 't', '™' => 'tm',
|
||||
'.' => '', '€' => 'E'
|
||||
);
|
||||
|
||||
$val = strtr( $val, $table );
|
||||
|
||||
return $val;
|
||||
}
|
||||
|
||||
public static function permissions_check( $g_user, $function )
|
||||
{
|
||||
switch ( $function ):
|
||||
case 'front\controls\GlobelusFirms\adverts_list':
|
||||
case 'front\controls\GlobelusFirms\advert_add':
|
||||
case 'front\controls\GlobelusFirms\advert_edit':
|
||||
case 'front\controls\GlobelusFirms\advert_answers':
|
||||
case 'front\controls\GlobelusFirms\advert_save':
|
||||
case 'front\controls\GlobelusFirms\advert_delete':
|
||||
case 'front\controls\GlobelusFirms\advert_enable':
|
||||
case 'front\controls\GlobelusFirms\advert_highlight_enable':
|
||||
case 'front\controls\GlobelusFirms\advert_highlight_disable':
|
||||
case 'front\controls\GlobelusFirms\advert_main_page_enable':
|
||||
case 'front\controls\GlobelusFirms\advert_main_page_disable':
|
||||
case 'front\controls\GlobelusFirms\advert_disable':
|
||||
case 'front\controls\GlobelusFirms\advert_extend':
|
||||
case 'front\controls\GlobelusFirms\advert_refresh':
|
||||
case 'front\controls\GlobelusFirms\profile_preview':
|
||||
case 'front\controls\GlobelusFirms\profile_edit':
|
||||
case 'front\controls\GlobelusFirms\profile_settings':
|
||||
case 'front\controls\GlobelusFirms\followed_candidates':
|
||||
case 'front\controls\GlobelusFirms\proposed_candidates':
|
||||
case 'front\controls\GlobelusFirms\candidate_add_to_favorite':
|
||||
case 'front\controls\GlobelusFirms\candidate_remove_from_favorite':
|
||||
case 'front\controls\GlobelusFirms\answer_delete':
|
||||
case 'front\controls\GlobelusFirms\data_save':
|
||||
case 'front\controls\GlobelusFirms\change_password':
|
||||
case 'front\controls\GlobelusFirms\buy_points':
|
||||
case 'front\controls\GlobelusFirms\create_order':
|
||||
case 'front\controls\GlobelusFirms\payment_success':
|
||||
case 'front\controls\GlobelusFirms\payment_error':
|
||||
case 'front\controls\GlobelusFirms\advert_additional_promotion':
|
||||
case 'front\controls\GlobelusFirms\answers':
|
||||
case 'front\controls\GlobelusCv\cv_list':
|
||||
case 'front\controls\GlobelusCv\candidate_profile':
|
||||
case 'front\controls\GlobelusCv\proposed_candidate_profile':
|
||||
case 'front\controls\GlobelusCv\activate_access':
|
||||
if ( $g_user and $g_user['type'] ) return true;
|
||||
break;
|
||||
case 'front\controls\GlobelusCandidates\profile_preview':
|
||||
case 'front\controls\GlobelusCandidates\profile_edit':
|
||||
case 'front\controls\GlobelusCandidates\data_save':
|
||||
case 'front\controls\GlobelusCandidates\profile_settings':
|
||||
case 'front\controls\GlobelusCandidates\change_password':
|
||||
case 'front\controls\GlobelusCandidates\profile_refresh':
|
||||
case 'front\controls\GlobelusCandidates\profile_extend':
|
||||
case 'front\controls\GlobelusCandidates\profile_enable':
|
||||
case 'front\controls\GlobelusCandidates\profile_disable':
|
||||
case 'front\controls\GlobelusCandidates\answers_list':
|
||||
case 'front\controls\GlobelusCandidates\adverts_list':
|
||||
case 'front\controls\GlobelusAdverts\send_message':
|
||||
case 'front\controls\GlobelusAdverts\remove_from_favorite':
|
||||
case 'front\controls\GlobelusAdverts\add_to_favorite':
|
||||
if ( $g_user and !$g_user['type'] ) return true;
|
||||
break;
|
||||
case 'front\controls\GlobelusUser\delete_account':
|
||||
if ( $g_user ) return true;
|
||||
break;
|
||||
endswitch;
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function logo_allowed_mime_types()
|
||||
{
|
||||
return [
|
||||
'image/jpeg',
|
||||
'image/png'
|
||||
];
|
||||
}
|
||||
public static function advert_add_img_bottom_allowed_mime_types()
|
||||
{
|
||||
return [
|
||||
'image/jpeg',
|
||||
'image/png'
|
||||
];
|
||||
}
|
||||
public static function advert_add_img_top_allowed_mime_types()
|
||||
{
|
||||
return [
|
||||
'image/jpeg',
|
||||
'image/png'
|
||||
];
|
||||
}
|
||||
public static function img_header_allowed_mime_types()
|
||||
{
|
||||
return [
|
||||
'image/jpeg',
|
||||
'image/png'
|
||||
];
|
||||
}
|
||||
public static function img_bottom_allowed_mime_types()
|
||||
{
|
||||
return [
|
||||
'image/jpeg',
|
||||
'image/png'
|
||||
];
|
||||
}
|
||||
|
||||
public static function avatar_allowed_mime_types()
|
||||
{
|
||||
return [
|
||||
'image/jpeg',
|
||||
'image/png'
|
||||
];
|
||||
}
|
||||
|
||||
public static function cv_allowed_mime_types()
|
||||
{
|
||||
return [
|
||||
'application/msword',
|
||||
'application/rft',
|
||||
'text/pdf',
|
||||
'application/pdf',
|
||||
'application/vnd.oasis.opendocument.text',
|
||||
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
||||
'image/jpeg'
|
||||
];
|
||||
}
|
||||
|
||||
public static function countries()
|
||||
{
|
||||
global $mdb;
|
||||
return $mdb -> select( 'globelus_countries', [ 'id', 'name' ], [ 'ORDER' => [ 'name' => 'ASC' ] ] );
|
||||
}
|
||||
|
||||
public static function availability_status()
|
||||
{
|
||||
return [ 1 => 'aktywnie szukam pracy, jestem gotowy zacząć od zaraz', 2 => 'szukam pracy, jestem dostępny od:', 3 => 'nie szukam pracy, ale jestem otwarty na propozycje' ];
|
||||
}
|
||||
|
||||
public static function languages_experience()
|
||||
{
|
||||
return [
|
||||
1 => 'znam tylko podstawowe zwroty, przywitania się, podziękowania, itp.',
|
||||
2 => 'potrafię budować proste zdania i rozumiem proste sformułowania',
|
||||
3 => 'potrafię budować złożone zdania i rozumiem złożone sformułowania',
|
||||
4 => 'mówię dobrze',
|
||||
5 => 'ojczysty'
|
||||
];
|
||||
}
|
||||
|
||||
public static function positions_experience()
|
||||
{
|
||||
global $lang;
|
||||
return [ 0 => 'nie posiadam doświadczenia', 1 => 'do 2 lat', 2 => '2-5 lat', 3 => '5-10 lat', 4 => 'powyżej 10 lat' ];
|
||||
}
|
||||
|
||||
public static function age_word_translations( $age )
|
||||
{
|
||||
global $lang;
|
||||
|
||||
if ( $age == 1 ) echo $lang['rok'];
|
||||
elseif ( $age > 1 and $age <= 4 ) echo $lang['lata'];
|
||||
elseif ( $age > 4 and $age <= 10 ) echo $lang['lat'];
|
||||
else
|
||||
{
|
||||
if ( $age%10 <= 1 ) echo $lang['lat'];
|
||||
else if ( $age%10 >= 2 and $age%10 <= 4 ) echo $lang['lata'];
|
||||
else if ( $age%10 >= 5 ) echo $lang['lat'];
|
||||
}
|
||||
}
|
||||
}
|
||||
620
autoload/front/factory/class.GlobelusAdverts.php
Normal file
620
autoload/front/factory/class.GlobelusAdverts.php
Normal file
@@ -0,0 +1,620 @@
|
||||
<?php
|
||||
namespace front\factory;
|
||||
class GlobelusAdverts
|
||||
{
|
||||
const advert_list_limit = 10;
|
||||
|
||||
static public function get_similar_adverts( $advert )
|
||||
{
|
||||
global $mdb;
|
||||
return $mdb -> rand( 'globelus_adverts', 'id', [ 'AND' => [ 'visible' => 1, 'category_id' => $advert['category_id'], 'id[!]' => $advert['id'] ], 'LIMIT' => 5 ] );
|
||||
}
|
||||
|
||||
public static function last_adverts( $limit = 3 )
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
return $mdb -> query( 'SELECT '
|
||||
. 'ga.id, title, date_add, gc.name AS country, ga.city, firm_name_profile, gac.name AS category, text, visits, ga.user_id, ga.highlight '
|
||||
. 'FROM '
|
||||
. 'globelus_adverts AS ga '
|
||||
. 'LEFT JOIN globelus_countries AS gc ON gc.id = country_id '
|
||||
. 'INNER JOIN globelus_firms_data AS gfd ON gfd.user_id = ga.user_id '
|
||||
. 'LEFT JOIN globelus_adverts_categories AS gac ON gac.id = ga.category_id '
|
||||
. 'WHERE '
|
||||
. 'visible = 1 '
|
||||
. 'AND '
|
||||
. '( active_to >= \'' . date( 'Y-m-d' ) . '\' OR active_to IS NULL ) '
|
||||
. 'ORDER BY '
|
||||
. 'date_add DESC '
|
||||
. 'LIMIT ' . $limit ) -> fetchAll( \PDO::FETCH_ASSOC );
|
||||
}
|
||||
|
||||
public static function main_page_adverts( $limit = 5 )
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
return $mdb -> query( 'SELECT '
|
||||
. 'ga.id, title, date_add, gc.name AS country, ga.city, firm_name_profile, gac.name AS category, text, visits, ga.user_id, ga.highlight '
|
||||
. 'FROM '
|
||||
. 'globelus_adverts AS ga '
|
||||
. 'LEFT JOIN globelus_countries AS gc ON gc.id = country_id '
|
||||
. 'INNER JOIN globelus_firms_data AS gfd ON gfd.user_id = ga.user_id '
|
||||
. 'LEFT JOIN globelus_adverts_categories AS gac ON gac.id = ga.category_id '
|
||||
. 'WHERE '
|
||||
. 'visible = 1 '
|
||||
. 'AND '
|
||||
. '( active_to >= \'' . date( 'Y-m-d' ) . '\' OR active_to IS NULL ) '
|
||||
. 'AND '
|
||||
. 'main_page = 1 '
|
||||
. 'ORDER BY RAND() '
|
||||
. 'LIMIT ' . $limit ) -> fetchAll( \PDO::FETCH_ASSOC );
|
||||
}
|
||||
|
||||
public static function top_firms( $limit = 5 )
|
||||
{
|
||||
global $mdb;
|
||||
return $mdb -> query( 'SELECT '
|
||||
. 'gfd.user_id, gfd.firm_name_profile, COUNT(gfd.id) AS cc '
|
||||
. 'FROM '
|
||||
. 'globelus_firms_data AS gfd '
|
||||
. 'INNER JOIN globelus_adverts AS ga ON ga.user_id = gfd.user_id '
|
||||
. 'WHERE '
|
||||
. 'visible = 1 '
|
||||
. 'AND '
|
||||
. '( active_to >= \'' . date( 'Y-m-d' ) . '\' OR active_to IS NULL ) '
|
||||
. 'GROUP BY '
|
||||
. 'gfd.user_id '
|
||||
. 'ORDER BY '
|
||||
. 'cc DESC, firm_name_profile ASC '
|
||||
. 'LIMIT ' . $limit ) -> fetchAll( \PDO::FETCH_ASSOC );
|
||||
}
|
||||
|
||||
public static function top_categories( $limit = 5 )
|
||||
{
|
||||
global $mdb;
|
||||
return $mdb -> query( 'SELECT '
|
||||
. 'gac.id, gac.name, COUNT(ga.id) AS cc '
|
||||
. 'FROM '
|
||||
. 'globelus_adverts_categories AS gac '
|
||||
. 'INNER JOIN globelus_adverts AS ga ON ga.category_id = gac.id '
|
||||
. 'WHERE '
|
||||
. 'visible = 1 '
|
||||
. 'AND '
|
||||
. '( active_to >= \'' . date( 'Y-m-d' ) . '\' OR active_to IS NULL ) '
|
||||
. 'GROUP BY '
|
||||
. 'gac.id '
|
||||
. 'ORDER BY '
|
||||
. 'cc DESC '
|
||||
. 'LIMIT ' . $limit ) -> fetchAll( \PDO::FETCH_ASSOC );
|
||||
}
|
||||
|
||||
public static function top_countries( $limit = 5 )
|
||||
{
|
||||
global $mdb;
|
||||
return $mdb -> query( 'SELECT '
|
||||
. 'gc.id, gc.name, COUNT(ga.id) AS cc '
|
||||
. 'FROM '
|
||||
. 'globelus_countries AS gc '
|
||||
. 'INNER JOIN globelus_adverts AS ga ON ga.country_id = gc.id '
|
||||
. 'WHERE '
|
||||
. 'visible = 1 '
|
||||
. 'AND '
|
||||
. '( active_to >= \'' . date( 'Y-m-d' ) . '\' OR active_to IS NULL ) '
|
||||
. 'GROUP BY '
|
||||
. 'gc.id '
|
||||
. 'ORDER BY '
|
||||
. 'cc DESC '
|
||||
. 'LIMIT ' . $limit ) -> fetchAll( \PDO::FETCH_ASSOC );
|
||||
}
|
||||
|
||||
public static function firms_list()
|
||||
{
|
||||
global $mdb;
|
||||
return $mdb -> query( 'SELECT '
|
||||
. 'gu.id, firm_name_profile '
|
||||
. 'FROM '
|
||||
. 'globelus_users AS gu '
|
||||
. 'INNER JOIN globelus_firms_data AS gfd ON gfd.user_id = gu.id '
|
||||
. 'WHERE '
|
||||
. 'gu.type = 1 '
|
||||
. 'AND '
|
||||
. 'gu.status = 1 '
|
||||
. 'AND '
|
||||
. 'gu.profile_completed = 1 '
|
||||
. 'ORDER BY '
|
||||
. 'gfd.firm_name ASC ' ) -> fetchAll( \PDO::FETCH_ASSOC );
|
||||
}
|
||||
|
||||
public static function refresh_count( $advert_id )
|
||||
{
|
||||
global $mdb;
|
||||
return $mdb -> get( 'globelus_adverts', 'refresh_count', [ 'id' => $advert_id ] );
|
||||
}
|
||||
|
||||
public static function last_refresh( $advert_id )
|
||||
{
|
||||
global $mdb;
|
||||
$row = $mdb -> get( 'globelus_adverts', [ 'date_add', 'last_refresh' ], [ 'id' => $advert_id ] );
|
||||
if ( $row['last_refresh'] )
|
||||
return $row['last_refresh'];
|
||||
else
|
||||
return $row['date_add'];
|
||||
}
|
||||
|
||||
public static function active_to( $advert_id )
|
||||
{
|
||||
global $mdb;
|
||||
return $mdb -> get( 'globelus_adverts', 'active_to', [ 'id' => $advert_id ] );
|
||||
}
|
||||
|
||||
public static function advert_visits_increase( $advert_id )
|
||||
{
|
||||
global $mdb;
|
||||
return $mdb -> update( 'globelus_adverts', [ 'visits[+]' => 1 ], [ 'AND' => [ 'visible' => 1, 'id' => $advert_id ] ] );
|
||||
}
|
||||
|
||||
public static function remove_from_favorite( $advert_id, $user_id )
|
||||
{
|
||||
global $mdb;
|
||||
return $mdb -> delete( 'globelus_candidates_adverts', [
|
||||
'AND' => [
|
||||
'advert_id' => $advert_id,
|
||||
'user_id' => $user_id
|
||||
]
|
||||
] );
|
||||
}
|
||||
|
||||
public static function add_to_favorite( $advert_id, $user_id )
|
||||
{
|
||||
global $mdb;
|
||||
return $mdb -> insert( 'globelus_candidates_adverts', [
|
||||
'advert_id' => $advert_id,
|
||||
'user_id' => $user_id
|
||||
] );
|
||||
}
|
||||
|
||||
public static function advert_title( int $advert_id )
|
||||
{
|
||||
global $mdb;
|
||||
return $mdb -> get( 'globelus_adverts', 'title', [ 'id' => (int)$advert_id ] );
|
||||
}
|
||||
|
||||
public static function advert_user_id( int $advert_id )
|
||||
{
|
||||
global $mdb;
|
||||
return $mdb -> get( 'globelus_adverts', 'user_id', [ 'id' => $advert_id ] );
|
||||
}
|
||||
|
||||
public static function send_message( $advert_id, $user_id = null, $name, $surname, $email, $phone, $text, $cv_file, $register )
|
||||
{
|
||||
global $mdb, $lang, $settings, $globelus_settings;
|
||||
|
||||
if ( $cv_file['tmp_name'] == '' and $user_id )
|
||||
{
|
||||
$cv = \front\factory\GlobelusCandidates::cv_url( $user_id );
|
||||
$extension = \front\factory\GlobelusCandidates::cv_extension( $user_id );
|
||||
}
|
||||
else if ( $cv_file['tmp_name'] == '' and \S::get_session( 'advert_answer_cv' ) )
|
||||
{
|
||||
$cv = \S::get_session( 'advert_answer_cv' );
|
||||
$extension = \S::get_session( 'advert_answer_cv_extension' );
|
||||
}
|
||||
else if ( $cv_file['tmp_name'] != '' )
|
||||
{
|
||||
$allowed_mime_types = \front\factory\Globelus::cv_allowed_mime_types();
|
||||
|
||||
if ( $cv_file["size"] > 5242880 )
|
||||
{
|
||||
\S::set_alert_prompt( 'Informacja', $lang['plik-cv-jest-zbyt-duzy'] );
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( !in_array( $cv_file["type"], $allowed_mime_types ) )
|
||||
{
|
||||
\S::set_alert_prompt( 'Informacja', $lang['cv-niedozwolony-format-pliku'] );
|
||||
return false;
|
||||
}
|
||||
|
||||
$cv_hash = \front\factory\GlobelusCandidates::cv_hash( time() );
|
||||
$dir = 'files/cv_tmp/' . $cv_hash{0} . '/' . $cv_hash{1} . '/';
|
||||
|
||||
if ( !is_dir( $dir ) )
|
||||
mkdir( $dir , 0755 , true );
|
||||
|
||||
$info = new \SplFileInfo( $cv_file['name'] );
|
||||
$extension = $info -> getExtension();
|
||||
|
||||
move_uploaded_file( $cv_file['tmp_name'], $dir . $cv_hash );
|
||||
$cv = $dir . $cv_hash;
|
||||
}
|
||||
|
||||
$mdb -> insert( 'globelus_adverts_answers', [
|
||||
'advert_id' => $advert_id,
|
||||
'user_id' => $user_id ? $user_id : null,
|
||||
'name' => $name,
|
||||
'surname' => $surname,
|
||||
'email' => $email,
|
||||
'phone' => $phone,
|
||||
'text' => $text,
|
||||
'cv' => $cv,
|
||||
'cv_extension' => $extension
|
||||
] );
|
||||
|
||||
if ( $answer_id = $mdb -> id() )
|
||||
{
|
||||
$text = $settings['newsletter_header'];
|
||||
$text .= \front\factory\Newsletter::get_template( '#powiadomienie-o-zlozonej-aplikacji' );
|
||||
$text .= $settings['newsletter_footer_1'];
|
||||
|
||||
$advert_title = self::advert_title( (int)$advert_id );
|
||||
$advert_user_id = self::advert_user_id( (int)$advert_id );
|
||||
|
||||
$settings['ssl'] ? $base = 'https' : $base = 'http';
|
||||
|
||||
$text = str_replace( '[LINK]', $base . "://" . $_SERVER['SERVER_NAME'] . "/login-as/" . \front\factory\GlobelusUser::get_hash( $advert_user_id ) . "?return_url=" . urlencode( '/panel-pracodawcy/odpowiedzi/' . $advert_id . '/' ), $text );
|
||||
|
||||
$regex = "-(<img[^>]+src\s*=\s*['\"])(((?!'|\"|https?://).)*)(['\"][^>]*>)-i";
|
||||
$text = preg_replace( $regex, "$1" . $base . "://" . $_SERVER['SERVER_NAME'] . "$2$4", $text );
|
||||
|
||||
$regex = "-(<a[^>]+href\s*=\s*['\"])(((?!'|\"|https?://).)*)(['\"][^>]*>)-i";
|
||||
$text = preg_replace( $regex, "$1" . $base . "://" . $_SERVER['SERVER_NAME'] . "$2$4", $text );
|
||||
|
||||
$text = str_replace( '[TYTUL_OGLOSZENIA]', $advert_title, $text );
|
||||
|
||||
if ( $globelus_settings['maile-wysylanie'] )
|
||||
\S::send_email( self::advert_email( $advert_id ), $lang['aplikacja-na-stanowisko'] . ' ' . $advert_title, $text );
|
||||
|
||||
\S::set_alert_prompt( 'Informacja', $lang['aplikacja-na-ogloszenie-zostala-wyslana'] );
|
||||
|
||||
if ( !$user_id )
|
||||
{
|
||||
\S::set_session( 'advert_answer_name', $name );
|
||||
\S::set_session( 'advert_answer_surname', $surname );
|
||||
\S::set_session( 'advert_answer_email', $email );
|
||||
\S::set_session( 'advert_answer_phone', $phone );
|
||||
\S::set_session( 'advert_answer_cv', $cv );
|
||||
\S::set_session( 'advert_answer_cv_extension', $extension );
|
||||
|
||||
if ( $register == 'on' )
|
||||
{
|
||||
if ( $cv_file['tmp_name'] == '' and \S::get_session( 'advert_answer_cv' ) )
|
||||
{
|
||||
$cv = \S::get_session( 'advert_answer_cv' );
|
||||
$extension = \S::get_session( 'advert_answer_cv_extension' );
|
||||
}
|
||||
|
||||
$password = \front\factory\Globelus::gen_password();
|
||||
\front\factory\GlobelusUser::signup( $email, $password, 0, 'on', 'off', true, $name, $surname, $phone, $cv_file, $cv, $extension, 1 );
|
||||
|
||||
$user_tmp_id = $mdb -> get( 'globelus_users', 'id', [ 'email' => $email ] );
|
||||
$mdb -> update( 'globelus_adverts_answers', [ 'user_id' => $user_tmp_id ], [ 'id' => $answer_id ] );
|
||||
$mdb -> update( 'globelus_users', [ 'profile_completed' => 1 ], [ 'id' => $user_tmp_id ] );
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function advert_email( $advert_id )
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
$email = $mdb -> get( 'globelus_adverts', 'email', [ 'id' => $advert_id ] );
|
||||
|
||||
if ( !$email )
|
||||
$email = $mdb -> get( 'globelus_users', 'email', [ 'id' => $mdb -> get( 'globelus_adverts', 'user_id', [ 'id' => $advert_id ] ) ] );
|
||||
|
||||
return $email;
|
||||
}
|
||||
|
||||
public static function adverts_count( $values, $voivodeships, $accommodation_provided )
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
if ( is_array( $values['categories'] ) and count( $values['categories'] ) )
|
||||
$filtr = 'AND category_id IN (' . implode( ',', $values['categories'] ) . ') ';
|
||||
|
||||
if ( $values['keyword'] )
|
||||
$filtr .= 'AND ( '
|
||||
. 'title_nopl LIKE :title_nopl '
|
||||
. 'OR '
|
||||
. 'firm_name_profile_nopl LIKE :firm_name_profile_nopl '
|
||||
. 'OR '
|
||||
. 'text_nopl LIKE :text_nopl '
|
||||
. 'OR '
|
||||
. 'country_nopl LIKE :country_nopl '
|
||||
. 'OR '
|
||||
. 'city_nopl LIKE :city_nopl '
|
||||
. ') ';
|
||||
|
||||
if ( is_array( $values['countries'] ) and count( $values['countries'] ) == 1 and $values['countries'][0] == 75 )
|
||||
$filtr .= '';
|
||||
else
|
||||
{
|
||||
if ( is_array( $values['countries'] ) and count( $values['countries'] ) == 1 and $values['countries'][0] == 77 )
|
||||
$filtr .= 'AND country_id NOT IN (1) ';
|
||||
elseif ( is_array( $values['countries'] ) and count( $values['countries'] ) )
|
||||
$filtr .= 'AND country_id IN (' . implode( ',', $values['countries'] ) . ') ';
|
||||
}
|
||||
|
||||
if ( is_array( $voivodeships ) and count( $voivodeships ) )
|
||||
{
|
||||
if ( count( $voivodeships ) == 1 and $voivodeships[0] == 1 )
|
||||
{}
|
||||
else
|
||||
$filtr .= 'AND id_voivodeship IN (' . implode( ',', $voivodeships ) . ') ';
|
||||
}
|
||||
// var_dump( $voivodeships );
|
||||
|
||||
switch ( $values['time'] ):
|
||||
case 1: $filtr .= 'AND date_active >= \'' . date( 'Y-m-d H:i:s', strtotime( '-24 hours', time() ) ) . '\' '; break;
|
||||
case 2: $filtr .= 'AND date_active >= \'' . date( 'Y-m-d H:i:s', strtotime( '-3 days', time() ) ) . '\' '; break;
|
||||
case 3: $filtr .= 'AND date_active >= \'' . date( 'Y-m-d H:i:s', strtotime( '-7 days', time() ) ) . '\' '; break;
|
||||
case 4: $filtr .= 'AND date_active >= \'' . date( 'Y-m-d H:i:s', strtotime( '-14 days', time() ) ) . '\' '; break;
|
||||
case 5: $filtr .= 'AND date_active >= \'' . date( 'Y-m-d H:i:s', strtotime( '-1 months', time() ) ) . '\' '; break;
|
||||
case 6: $filtr .= 'AND date_active >= \'' . date( 'Y-m-d H:i:s', strtotime( '-2 months', time() ) ) . '\' '; break;
|
||||
endswitch;
|
||||
|
||||
if ( is_array( $values['work_types'] ) and ( count( $values['work_types'] ) > 1 or ( count( $values['work_types'] ) == 1 and $values['work_types'][0] != 0 ) ) )
|
||||
{
|
||||
$filtr_work_type = ' (';
|
||||
foreach ( $values['work_types'] as $work_type )
|
||||
$filtr_work_type .= ' OR work_type = ' . (int)$work_type . ' ';
|
||||
$filtr_work_type .= ') ';
|
||||
}
|
||||
|
||||
if ( (int)$values['work_type'] )
|
||||
$filtr .= 'AND work_type = ' . (int)$values['work_type'] . ' ';
|
||||
|
||||
// if ( (int)$values['work_type'] )
|
||||
// $filtr .= 'AND work_type = ' . (int)$values['work_type'] . ' ';
|
||||
|
||||
if ( (int)$values['salary'] )
|
||||
$filtr .= 'AND salary IS NOT NULL ';
|
||||
|
||||
if ( (int)$values['without_language'] )
|
||||
$filtr .= 'AND without_language = 1 ';
|
||||
|
||||
if ( (int)$values['without_experience'] )
|
||||
$filtr .= 'AND without_experience = 1 ';
|
||||
|
||||
if ( (int)$values['for_couples'] )
|
||||
$filtr .= 'AND for_couples = 1 ';
|
||||
|
||||
if ( (int)$values['outside_eu'] )
|
||||
$filtr .= 'AND outside_ue = 1 ';
|
||||
|
||||
if ( (int)$values['without_driving_license'] )
|
||||
$filtr .= 'AND without_driving_license = 1 ';
|
||||
|
||||
if ( (int)$values['travel_refund'] )
|
||||
$filtr .= 'AND travel_refund = 1 ';
|
||||
|
||||
if ( (int)$accommodation_provided )
|
||||
{
|
||||
$filtr .= 'AND accommodation = 1 ';
|
||||
}
|
||||
|
||||
/* SQL */
|
||||
$sql = 'SELECT COUNT(0) '
|
||||
. 'FROM ('
|
||||
. 'SELECT '
|
||||
. 'ga.id, title, title_nopl, date_add, gc.name AS country, gc.name_nopl AS country_nopl, ga.city, ga.city_nopl, firm_name_profile, firm_name_profile_nopl, gac.name AS category, text, text_nopl, visits, ga.user_id, ga.highlight, category_id, '
|
||||
. 'ga.country_id, IF ( last_refresh IS NULL, date_add, last_refresh ) AS date_active, work_type, salary, without_language, without_experience, for_couples, from_now, outside_ue, without_driving_license, travel_refund, id_voivodeship '
|
||||
. 'FROM '
|
||||
. 'globelus_adverts AS ga '
|
||||
. 'INNER JOIN globelus_countries AS gc ON gc.id = country_id ';
|
||||
|
||||
if ( is_array( $voivodeships ) and count( $voivodeships ) )
|
||||
$sql .= 'INNER JOIN globelus_voivodeships AS gv ON gv.id = id_voivodeship ';
|
||||
|
||||
$sql .= 'INNER JOIN globelus_firms_data AS gfd ON gfd.user_id = ga.user_id '
|
||||
. 'INNER JOIN globelus_adverts_categories AS gac ON gac.id = ga.category_id '
|
||||
. 'WHERE '
|
||||
. 'visible = 1 '
|
||||
. 'AND '
|
||||
. 'disabled_by_admin = 0 '
|
||||
. 'AND '
|
||||
. ' ( active_to >= \'' . date( 'Y-m-d' ) . '\' OR active_to IS NULL ) '
|
||||
. 'AND '
|
||||
. '( '
|
||||
. '( last_refresh IS NULL AND date_add >= \'' . date( 'Y-m-d H:i:s', strtotime( '-6 months', time() ) ) . '\' ) '
|
||||
. 'OR '
|
||||
. '( last_refresh IS NOT NULL AND last_refresh >= \'' . date( 'Y-m-d', strtotime( '-6 months', time() ) ) . '\' ) '
|
||||
. ') '
|
||||
. ') AS q1 '
|
||||
. 'WHERE '
|
||||
. '1=1 '
|
||||
. $filtr;
|
||||
// echo $sql;
|
||||
try
|
||||
{
|
||||
$result = $mdb -> query( $sql, [
|
||||
':firm_name_profile_nopl' => '%' . \S::seo( $values['keyword'], true ) . '%',
|
||||
':title_nopl' => '%' . \S::seo( $values['keyword'], true ) . '%',
|
||||
':text_nopl' => '%' . \S::seo( $values['keyword'], true ) . '%',
|
||||
':country_nopl' => '%' . \S::seo( $values['keyword'], true ) . '%',
|
||||
':city_nopl' => '%' . \S::seo( $values['keyword'], true ) . '%'
|
||||
] ) -> fetch();
|
||||
}
|
||||
catch ( \Throwable $t )
|
||||
{
|
||||
\S::pre( $mdb -> error() );
|
||||
$debug = debug_backtrace(true);
|
||||
echo $debug[0]['file'] . ' | ' . $debug[0]['line'];
|
||||
exit;
|
||||
}
|
||||
|
||||
return $result[0];
|
||||
}
|
||||
|
||||
public static function adverts_list( $values, $voivodeships, $accommodation_provided )
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
if ( $values['start'] < 1 )
|
||||
$values['start'] = 0;
|
||||
else
|
||||
$values['start']--;
|
||||
|
||||
if ( is_array( $values['categories'] ) and count( $values['categories'] ) )
|
||||
$filtr .= 'AND category_id IN (' . implode( ',', $values['categories'] ) . ') ';
|
||||
|
||||
if ( $values['keyword'] )
|
||||
$filtr .= 'AND ( '
|
||||
. 'title_nopl LIKE :title_nopl '
|
||||
. 'OR '
|
||||
. 'firm_name_profile_nopl LIKE :firm_name_profile_nopl '
|
||||
. 'OR '
|
||||
. 'text_nopl LIKE :text_nopl '
|
||||
. 'OR '
|
||||
. 'country_nopl LIKE :country_nopl '
|
||||
. 'OR '
|
||||
. 'city_nopl LIKE :city_nopl '
|
||||
. ') ';
|
||||
|
||||
if ( is_array( $values['countries'] ) and count( $values['countries'] ) == 1 and $values['countries'][0] == 75 )
|
||||
$filtr .= '';
|
||||
else
|
||||
{
|
||||
if ( is_array( $values['countries'] ) and count( $values['countries'] ) == 1 and $values['countries'][0] == 77 )
|
||||
$filtr .= 'AND country_id NOT IN (1) ';
|
||||
elseif ( is_array( $values['countries'] ) and count( $values['countries'] ) )
|
||||
$filtr .= 'AND country_id IN (' . implode( ',', $values['countries'] ) . ') ';
|
||||
}
|
||||
|
||||
if ( is_array( $voivodeships ) and count( $voivodeships ) )
|
||||
{
|
||||
if ( count( $voivodeships ) == 1 and $voivodeships[0] == 1 )
|
||||
{}
|
||||
else
|
||||
$filtr .= 'AND id_voivodeship IN (' . implode( ',', $voivodeships ) . ') ';
|
||||
}
|
||||
|
||||
switch ( $values['time'] ):
|
||||
case 1: $filtr .= 'AND date_active >= \'' . date( 'Y-m-d H:i:s', strtotime( '-24 hours', time() ) ) . '\' '; break;
|
||||
case 2: $filtr .= 'AND date_active >= \'' . date( 'Y-m-d H:i:s', strtotime( '-3 days', time() ) ) . '\' '; break;
|
||||
case 3: $filtr .= 'AND date_active >= \'' . date( 'Y-m-d H:i:s', strtotime( '-7 days', time() ) ) . '\' '; break;
|
||||
case 4: $filtr .= 'AND date_active >= \'' . date( 'Y-m-d H:i:s', strtotime( '-14 days', time() ) ) . '\' '; break;
|
||||
case 5: $filtr .= 'AND date_active >= \'' . date( 'Y-m-d H:i:s', strtotime( '-1 months', time() ) ) . '\' '; break;
|
||||
case 6: $filtr .= 'AND date_active >= \'' . date( 'Y-m-d H:i:s', strtotime( '-2 months', time() ) ) . '\' '; break;
|
||||
endswitch;
|
||||
|
||||
if ( is_array( $values['work_types'] ) and ( count( $values['work_types'] ) > 1 or ( count( $values['work_types'] ) == 1 and $values['work_types'][0] != 0 ) ) )
|
||||
{
|
||||
$filtr_work_type = ' (';
|
||||
foreach ( $values['work_types'] as $work_type )
|
||||
$filtr_work_type .= ' OR work_type = ' . (int)$work_type . ' ';
|
||||
$filtr_work_type .= ') ';
|
||||
}
|
||||
|
||||
if ( (int)$values['work_type'] )
|
||||
$filtr .= 'AND work_type = ' . (int)$values['work_type'] . ' ';
|
||||
|
||||
if ( (int)$values['salary'] )
|
||||
$filtr .= 'AND salary IS NOT NULL ';
|
||||
|
||||
if ( (int)$values['without_language'] )
|
||||
$filtr .= 'AND without_language = 1 ';
|
||||
|
||||
if ( (int)$values['without_experience'] )
|
||||
$filtr .= 'AND without_experience = 1 ';
|
||||
|
||||
if ( (int)$values['for_couples'] )
|
||||
$filtr .= 'AND for_couples = 1 ';
|
||||
|
||||
if ( (int)$values['outside_ue'] )
|
||||
$filtr .= 'AND outside_ue = 1 ';
|
||||
|
||||
if ( (int)$values['without_driving_license'] )
|
||||
$filtr .= 'AND without_driving_license = 1 ';
|
||||
|
||||
if ( (int)$values['travel_refund'] )
|
||||
$filtr .= 'AND travel_refund = 1 ';
|
||||
|
||||
if ( (int)$accommodation_provided )
|
||||
{
|
||||
$filtr .= 'AND accommodation = 1 ';
|
||||
}
|
||||
|
||||
if ( (int)$values['sort'] )
|
||||
$order = 'date_active DESC ';
|
||||
else
|
||||
$order = 'highlight DESC, date_active DESC ';
|
||||
|
||||
/* SQL */
|
||||
$sql = 'SELECT * '
|
||||
. 'FROM ('
|
||||
. 'SELECT '
|
||||
. 'ga.id, title, title_nopl, date_add, gc.name AS country, gc.name_nopl AS country_nopl, ga.city, ga.city_nopl, firm_name_profile, firm_name_profile_nopl, gac.name AS category, text, text_nopl, visits, ga.user_id, ga.highlight, category_id, '
|
||||
. 'ga.country_id, IF ( last_refresh IS NULL, date_add, last_refresh ) AS date_active, last_refresh, work_type, salary, without_language, without_experience, for_couples, from_now, overtime, overtime_quantity, accommodation, accommodation_cost, '
|
||||
. 'travel_refund, outside_ue, without_driving_license, id_voivodeship '
|
||||
. 'FROM '
|
||||
. 'globelus_adverts AS ga '
|
||||
. 'INNER JOIN globelus_countries AS gc ON gc.id = country_id ';
|
||||
|
||||
// jeżeli wybrano jakiekolwiek województwo
|
||||
if ( is_array( $voivodeships ) and count( $voivodeships ) )
|
||||
$sql .= 'INNER JOIN globelus_voivodeships AS gv ON gv.id = id_voivodeship ';
|
||||
|
||||
$sql .= 'INNER JOIN globelus_firms_data AS gfd ON gfd.user_id = ga.user_id '
|
||||
. 'INNER JOIN globelus_adverts_categories AS gac ON gac.id = ga.category_id '
|
||||
. 'WHERE '
|
||||
. 'visible = 1 '
|
||||
. 'AND '
|
||||
. 'disabled_by_admin = 0 '
|
||||
. 'AND '
|
||||
. ' ( active_to >= \'' . date( 'Y-m-d' ) . '\' OR active_to IS NULL ) '
|
||||
. ') AS q1 '
|
||||
. 'WHERE '
|
||||
. '1=1 '
|
||||
. $filtr
|
||||
. 'ORDER BY '
|
||||
. $order
|
||||
. 'LIMIT ' . ( $values['start'] * $values['limit'] ) . ',' . $values['limit'];
|
||||
|
||||
try
|
||||
{
|
||||
$results = $mdb -> query( $sql, [
|
||||
':title_nopl' => '%' . \S::seo( $values['keyword'], true ) . '%',
|
||||
':firm_name_profile_nopl' => '%' . \S::seo( $values['keyword'], true ) . '%',
|
||||
':text_nopl' => '%' . \S::seo( $values['keyword'], true ) . '%',
|
||||
':country_nopl' => '%' . \S::seo( $values['keyword'], true ) . '%',
|
||||
'city_nopl' => '%' . \S::seo( $values['keyword'], true ) . '%'
|
||||
] ) -> fetchAll( \PDO::FETCH_ASSOC );
|
||||
}
|
||||
catch ( \Throwable $t )
|
||||
{
|
||||
\S::pre( $mdb -> error() );
|
||||
$debug = debug_backtrace(true);
|
||||
echo $debug[0]['file'] . ' | ' . $debug[0]['line'];
|
||||
exit;
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
public static function advert_details( $advert_id )
|
||||
{
|
||||
global $mdb;
|
||||
return $mdb -> query( 'SELECT '
|
||||
. 'ga.id, title, ga.user_id, category_id, ga.country_id, ga.city, ga.region, text, contact_person, email, ga.phone, contact_person2, email2, ga.phone2, gfd.clauses, '
|
||||
. 'gac.name AS category_name, gc.name AS country_name, gfd.firm_name_profile, date_add, salary, work_type, without_language, '
|
||||
. 'without_experience, for_couples, from_now, accommodation, accommodation_cost, overtime, overtime_quantity, travel_refund, outside_ue, without_driving_license, ga.old, ga.visible, id_voivodeship, aplication_link, id_position '
|
||||
. 'FROM '
|
||||
. 'globelus_adverts AS ga '
|
||||
. 'LEFT JOIN globelus_adverts_categories AS gac ON gac.id = ga.category_id '
|
||||
. 'LEFT JOIN globelus_countries AS gc ON gc.id = ga.country_id '
|
||||
. 'LEFT JOIN globelus_firms_data AS gfd ON gfd.user_id = ga.user_id '
|
||||
. 'WHERE '
|
||||
. 'ga.id = ' . (int)$advert_id ) -> fetch( \PDO::FETCH_ASSOC );
|
||||
}
|
||||
|
||||
public static function categories( $user_categories = '' )
|
||||
{
|
||||
global $mdb;
|
||||
return $mdb -> select( 'globelus_adverts_categories', [ 'id', 'name' ], [ 'ORDER' => [ 'name' => 'ASC' ] ] );
|
||||
}
|
||||
}
|
||||
619
autoload/front/factory/class.GlobelusCandidates.php
Normal file
619
autoload/front/factory/class.GlobelusCandidates.php
Normal file
@@ -0,0 +1,619 @@
|
||||
<?php
|
||||
namespace front\factory;
|
||||
class GlobelusCandidates
|
||||
{
|
||||
public static function register_candidate( $email, $name, $surname, $phone, $date_of_birth, $sex, $positions, $positions_experience, $inexperience, $categories, $languages, $languages_experience,
|
||||
$countries, $voivodeships, $status_of_availability, $date_of_availability, $experience_abroad, $accommodation, $driving_license, $own_car, $other_information, $cv_file, $avatar_file )
|
||||
{
|
||||
global $mdb, $settings;
|
||||
|
||||
$result = [ 'status' => 'bad', 'msg' => \S::lang( 'rejestracja-blad-ogolny' ) ];
|
||||
|
||||
if ( $mdb -> count( 'globelus_users', [ 'email' => $email ] ) )
|
||||
return $result = [ 'status' => 'bad', 'msg' => 'Mamy juz Twój adres w naszej bazie, jeśli nie pamiętasz hasła do swojego konta kliknij <a href="/odzyskiwanie-hasla">tutaj</a>.' ];
|
||||
|
||||
/* obsługa cv */
|
||||
$allowed_mime_types = \front\factory\Globelus::cv_allowed_mime_types();
|
||||
|
||||
if ( $cv_file['tmp_name'] and $cv_file["size"] > 5242880 )
|
||||
return $result = [ 'status' => 'bad', 'msg' => \S::lang( 'plik-cv-jest-zbyt-duzy' ) ];
|
||||
|
||||
if ( $cv_file['tmp_name'] and !$cv_error and !in_array( $cv_file["type"], $allowed_mime_types ) )
|
||||
return $result = [ 'status' => 'bad', 'msg' => \S::lang( 'cv-niedozwolony-format-pliku' ) ];
|
||||
|
||||
/* obsługa avatarów */
|
||||
$allowed_mime_types = \front\factory\Globelus::avatar_allowed_mime_types();
|
||||
|
||||
if ( $avatar_file['tmp_name'] and $avatar_file["size"] > 1048576 )
|
||||
return $result = [ 'status' => 'bad', 'msg' => \S::lang( 'plik-zdjecie-jest-zbyt-duzy' ) ];
|
||||
|
||||
if ( $avatar_file['tmp_name'] and !$avatar_error and !in_array( $avatar_file["type"], $allowed_mime_types ) )
|
||||
return $result = [ 'status' => 'bad', 'msg' => \S::lang( 'zdjecie-niedozwolony-format-pliku' ) ];
|
||||
|
||||
$hash = md5( time() . $email );
|
||||
$register_date = date('Y-m-d H:i:s');
|
||||
$password = md5( time() );
|
||||
|
||||
$mdb -> insert( 'globelus_users', [
|
||||
'email' => $email,
|
||||
'password' => md5( $register_date . $password ),
|
||||
'hash' => $hash,
|
||||
'type' => 0,
|
||||
'user_agremment_profile' => 1,
|
||||
'user_agremment_marketing' => 1,
|
||||
'register_date' => $register_date,
|
||||
'active_to' => date( 'Y-m-d', strtotime( '+90 days', time() ) ),
|
||||
'auto_create' => 0,
|
||||
'status' => 1,
|
||||
'profile_completed' => 1,
|
||||
'visible' => 1
|
||||
] );
|
||||
|
||||
$user_id = $mdb -> id();
|
||||
|
||||
$mdb -> insert( 'globelus_candidates_data', [
|
||||
'user_id' => $user_id,
|
||||
'name' => $name,
|
||||
'surname' => $surname,
|
||||
'date_of_birth' => $date_of_birth ? date( 'Y-m-d', strtotime( $date_of_birth ) ) : null,
|
||||
'sex' => $sex === '' ? null : $sex,
|
||||
'phone' => $phone,
|
||||
'experience_abroad' => $experience_abroad === '' ? null : $experience_abroad,
|
||||
'status_of_availability' => $status_of_availability,
|
||||
'date_of_availability' => $date_of_availability,
|
||||
'accommodation' => $accommodation === '' ? null : $accommodation,
|
||||
'driving_license' => $driving_license === '' ? null : $driving_license,
|
||||
'own_car' => $own_car === '' ? null : $own_car,
|
||||
'inexperience' => $inexperience == 'on' ? 1 : 0,
|
||||
'other_information' => $other_information
|
||||
] );
|
||||
|
||||
$mdb -> update( 'globelus_users', [ 'profile_completed' => 1 ], [ 'id' => $user_id ] );
|
||||
|
||||
/* doświadczenie */
|
||||
if ( !$inexperience )
|
||||
{
|
||||
for ( $i = 0; $i < count( $positions ); $i++ )
|
||||
{
|
||||
if ( $positions[$i] )
|
||||
$mdb -> insert( 'globelus_candidates_positions', [
|
||||
'user_id' => $user_id,
|
||||
'id_position' => $positions[$i],
|
||||
'experience' => $positions_experience[$i]
|
||||
] );
|
||||
}
|
||||
}
|
||||
|
||||
/* języki */
|
||||
for ( $i = 0; $i < count( $languages ); $i++ )
|
||||
{
|
||||
if ( $languages[$i] and $languages_experience[$i] )
|
||||
$mdb -> insert( 'globelus_candidates_languages', [
|
||||
'user_id' => $user_id,
|
||||
'language' => $languages[$i],
|
||||
'experience' => $languages_experience[$i]
|
||||
] );
|
||||
}
|
||||
|
||||
/* kraje */
|
||||
for ( $i = 0; $i < count( $countries ); $i++ )
|
||||
{
|
||||
if ( $countries[$i] and !$mdb -> count( 'globelus_candidates_countries', [ 'AND' => [ 'user_id' => $user_id, 'country_id' => $countries[$i] ] ] ) )
|
||||
$mdb -> insert( 'globelus_candidates_countries', [
|
||||
'user_id' => $user_id,
|
||||
'country_id' => $countries[$i],
|
||||
] );
|
||||
}
|
||||
|
||||
/* wojewodztwa */
|
||||
for ( $i = 0; $i < count( $voivodeships ); $i++ )
|
||||
{
|
||||
if ( $voivodeships[$i] and !$mdb -> count( 'globelus_candidates_voivodeships', [ 'AND' => [ 'id_user' => $user_id, 'id_voivodeship' => $voivodeships[$i] ] ] ) )
|
||||
$mdb -> insert( 'globelus_candidates_voivodeships', [
|
||||
'id_user' => $user_id,
|
||||
'id_voivodeship' => $voivodeships[$i],
|
||||
] );
|
||||
}
|
||||
|
||||
/* branże */
|
||||
for ( $i = 0; $i < count( $categories ); $i++ )
|
||||
{
|
||||
if ( $categories[$i] and !$mdb -> count( 'globelus_candidates_categories', [ 'AND' => [ 'user_id' => $user_id, 'category_id' => $categories[$i] ] ] ) )
|
||||
$mdb -> insert( 'globelus_candidates_categories', [
|
||||
'user_id' => $user_id,
|
||||
'category_id' => $categories[$i],
|
||||
] );
|
||||
}
|
||||
|
||||
if ( $cv_file['tmp_name'] and !$cv_error )
|
||||
{
|
||||
$cv_hash = \front\factory\GlobelusCandidates::cv_hash( $user_id );
|
||||
$dir = 'files/cv/' . $cv_hash{0} . '/' . $cv_hash{1} . '/';
|
||||
|
||||
if ( !is_dir( $dir ) )
|
||||
mkdir( $dir , 0755 , true );
|
||||
|
||||
$info = new \SplFileInfo( $cv_file['name'] );
|
||||
$file_ext = $info -> getExtension();
|
||||
|
||||
move_uploaded_file( $cv_file['tmp_name'], $dir . $cv_hash );
|
||||
|
||||
$mdb -> update( 'globelus_candidates_data', [ 'cv_extension' => $file_ext ], [ 'user_id' => $user_id ] );
|
||||
}
|
||||
|
||||
if ( $avatar_file['tmp_name'] and !$avatar_error )
|
||||
{
|
||||
$avatar_hash = \front\factory\GlobelusCandidates::avatar_hash( $user_id );
|
||||
$dir = 'files/avatars/' . $avatar_hash{0} . '/' . $avatar_hash{1} . '/';
|
||||
|
||||
if ( !is_dir( $dir ) )
|
||||
mkdir( $dir , 0755 , true );
|
||||
|
||||
$info = new \SplFileInfo( $avatar_file['name'] );
|
||||
$file_ext = $info -> getExtension();
|
||||
|
||||
move_uploaded_file( $avatar_file['tmp_name'], $dir . $avatar_hash );
|
||||
|
||||
$mdb -> update( 'globelus_candidates_data', [ 'avatar_extension' => $file_ext ], [ 'user_id' => $user_id ] );
|
||||
}
|
||||
|
||||
$text = $settings['newsletter_header'];
|
||||
$text .= \front\factory\Newsletter::get_template( '#globelus-potwierdzenie-automatycznej-rejestracji' );
|
||||
$text .= '<p style="font-size: 13px; font-style: italic; color:#95a5a6; padding: 0 20px;">' . \S::lang( 'rejestracja-kandydat-ostrzezenie' ) . '</p>';
|
||||
|
||||
$text .= $settings['newsletter_footer_1'];
|
||||
|
||||
$settings['ssl'] ? $base = 'https' : $base = 'http';
|
||||
|
||||
$regex = "-(<img[^>]+src\s*=\s*['\"])(((?!'|\"|https?://).)*)(['\"][^>]*>)-i";
|
||||
$text = preg_replace( $regex, "$1" . $base . "://" . $_SERVER['SERVER_NAME'] . "$2$4", $text );
|
||||
|
||||
$regex = "-(<a[^>]+href\s*=\s*['\"])(((?!'|\"|https?://).)*)(['\"][^>]*>)-i";
|
||||
$text = preg_replace( $regex, "$1" . $base . "://" . $_SERVER['SERVER_NAME'] . "$2$4", $text );
|
||||
|
||||
$text = str_replace( '[LOGIN]', $email, $text );
|
||||
$text = str_replace( '[HASLO]', $password, $text );
|
||||
|
||||
$send = \S::send_email( $email, \S::lang( 'potwierdzenie-rejestracji-konta-w-portalu' ) . ' GLOBELUS.PL', $text );
|
||||
|
||||
\front\factory\GlobelusUser::signin( null, null, null, null, $hash );
|
||||
|
||||
return $result = [ 'status' => 'ok', 'msg' => 'Twoje konto zostało założone. Dane do logowania zostały wysłane na podany adres email.' ];
|
||||
}
|
||||
|
||||
public static function candidate_categories( $user_id )
|
||||
{
|
||||
global $mdb;
|
||||
return $mdb -> query( 'SELECT '
|
||||
. 'name '
|
||||
. 'FROM '
|
||||
. 'globelus_adverts_categories AS gac '
|
||||
. 'INNER JOIN globelus_candidates_categories AS gcc ON gcc.category_id = gac.id '
|
||||
. 'WHERE '
|
||||
. 'gcc.user_id = ' . (int)$user_id ) -> fetchAll( \PDO::FETCH_ASSOC );
|
||||
}
|
||||
|
||||
public static function candidate_positions( $user_id )
|
||||
{
|
||||
global $mdb;
|
||||
return $mdb -> select( 'globelus_candidates_positions', [ 'position', 'experience', 'id_position' ], [ 'user_id' => $user_id ] );
|
||||
}
|
||||
|
||||
public static function avatar_extension( $user_id )
|
||||
{
|
||||
global $mdb;
|
||||
return $mdb -> get( 'globelus_candidates_data', 'avatar_extension', [ 'user_id' => $user_id ] );
|
||||
}
|
||||
|
||||
public static function avatar_url( $user_id )
|
||||
{
|
||||
$avatar_hash = \front\factory\GlobelusCandidates::avatar_hash( $user_id );
|
||||
return $file_name = 'files/avatars/' . $avatar_hash{0} . '/' . $avatar_hash{1} . '/' . $avatar_hash;
|
||||
}
|
||||
|
||||
public static function avatar( $user_id, $token )
|
||||
{
|
||||
if ( $_SESSION['tokens'][$token] )
|
||||
{
|
||||
$avatar_hash = \front\factory\GlobelusCandidates::avatar_hash( $user_id );
|
||||
$extension = \front\factory\GlobelusCandidates::avatar_extension( $user_id );
|
||||
$file_name = 'files/avatars/' . $avatar_hash{0} . '/' . $avatar_hash{1} . '/' . $avatar_hash;
|
||||
|
||||
if ( file_exists( $file_name ) )
|
||||
{
|
||||
switch( $extension ):
|
||||
case "png": $ctype="image/png"; break;
|
||||
case "jpeg":
|
||||
case "jpg": $ctype="image/jpeg"; break;
|
||||
default:
|
||||
endswitch;
|
||||
|
||||
header( 'Content-Type: ' . $ctype );
|
||||
readfile( $file_name );
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function cv_tmp_download( $answer_id, $token )
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
if ( $_SESSION['tokens'][$token] )
|
||||
{
|
||||
$cv_info = $mdb -> get( 'globelus_adverts_answers', [ 'cv', 'cv_extension' ], [ 'id' => $answer_id ] );
|
||||
|
||||
if ( file_exists( $cv_info['cv'] ) )
|
||||
{
|
||||
$tmp_filename = "cv." . $cv_info['cv_extension'];
|
||||
$file_name = $cv_info['cv'];
|
||||
|
||||
header("Content-type: application/pdf");
|
||||
header("Content-type: octet-stream");
|
||||
header( "Content-Disposition: attachment; filename=$tmp_filename" );
|
||||
header( "Content-Length: " . filesize( $file_name ) );
|
||||
readfile( $file_name );
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function profile_visits_increase( $candidate_id, $firm_id )
|
||||
{
|
||||
global $mdb;
|
||||
$mdb -> insert( 'globelus_candidates_visits', [
|
||||
'candidate_id' => $candidate_id,
|
||||
'firm_id' => $firm_id
|
||||
] );
|
||||
return $mdb -> update( 'globelus_users', [ 'visits[+]' => 1 ], [ 'id' => $candidate_id ] );
|
||||
}
|
||||
|
||||
public static function adverts_list( $user_id )
|
||||
{
|
||||
global $mdb;
|
||||
return $mdb -> query( 'SELECT '
|
||||
. 'ga.title, ga.date_add, ga.user_id, ga.id, gc.name AS country, ga.city, firm_name_profile, gac.name AS category, text '
|
||||
. 'FROM '
|
||||
. 'globelus_adverts AS ga '
|
||||
. 'INNER JOIN globelus_candidates_adverts AS gca ON gca.advert_id = ga.id '
|
||||
. 'LEFT JOIN globelus_countries AS gc ON gc.id = ga.country_id '
|
||||
. 'INNER JOIN globelus_firms_data AS gfd ON gfd.user_id = ga.user_id '
|
||||
. 'LEFT JOIN globelus_adverts_categories AS gac ON gac.id = ga.category_id '
|
||||
. 'WHERE '
|
||||
. 'gca.user_id = ' . (int)$user_id . ' '
|
||||
. 'AND '
|
||||
. 'ga.visible = 1 '
|
||||
. 'ORDER BY '
|
||||
. 'ga.date_add DESC' ) -> fetchAll( \PDO::FETCH_ASSOC );
|
||||
}
|
||||
|
||||
public static function answers_list( $user_id )
|
||||
{
|
||||
global $mdb;
|
||||
return $mdb -> query( 'SELECT '
|
||||
. 'ga.title, gaa.date_add, gaa.text, displayed, ga.user_id, ga.id '
|
||||
. 'FROM '
|
||||
. 'globelus_adverts AS ga '
|
||||
. 'INNER JOIN globelus_adverts_answers AS gaa ON gaa.advert_id = ga.id '
|
||||
. 'WHERE '
|
||||
. 'gaa.user_id = ' . (int)$user_id . ' '
|
||||
. 'AND '
|
||||
. 'ga.visible = 1 '
|
||||
. 'ORDER BY '
|
||||
. 'gaa.date_add DESC' ) -> fetchAll( \PDO::FETCH_ASSOC );
|
||||
}
|
||||
|
||||
public static function cv_extension( $user_id )
|
||||
{
|
||||
global $mdb;
|
||||
return $mdb -> get( 'globelus_candidates_data', 'cv_extension', [ 'user_id' => $user_id ] );
|
||||
}
|
||||
|
||||
public static function avatar_hash( $user_id )
|
||||
{
|
||||
return md5( 'files/avatars/' . $user_id . '/' );
|
||||
}
|
||||
|
||||
public static function cv_hash( $user_id )
|
||||
{
|
||||
return md5( 'files/cv/' . $user_id . '/' );
|
||||
}
|
||||
|
||||
public static function cv_url( $user_id )
|
||||
{
|
||||
$cv_hash = \front\factory\GlobelusCandidates::cv_hash( $user_id );
|
||||
return $file_name = 'files/cv/' . $cv_hash{0} . '/' . $cv_hash{1} . '/' . $cv_hash;
|
||||
}
|
||||
|
||||
public static function cv_download( $user_id, $token )
|
||||
{
|
||||
if ( $_SESSION['tokens'][$token] )
|
||||
{
|
||||
$cv_hash = \front\factory\GlobelusCandidates::cv_hash( $user_id );
|
||||
$extension = \front\factory\GlobelusCandidates::cv_extension( $user_id );
|
||||
$file_name = 'files/cv/' . $cv_hash{0} . '/' . $cv_hash{1} . '/' . $cv_hash;
|
||||
|
||||
if ( file_exists( $file_name ) )
|
||||
{
|
||||
$tmp_filename = "cv." . $extension;
|
||||
|
||||
header("Content-type: octet-stream");
|
||||
header( "Content-Disposition: attachment; filename=$tmp_filename" );
|
||||
header( "Content-Length: " . filesize( $file_name ) );
|
||||
readfile( $file_name );
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function profile_disable( $user_id )
|
||||
{
|
||||
global $mdb;
|
||||
return $mdb -> update( 'globelus_users', [
|
||||
'visible' => 0
|
||||
], [
|
||||
'id' => $user_id
|
||||
] );
|
||||
}
|
||||
|
||||
public static function profile_enable( $user_id, $email = '' )
|
||||
{
|
||||
|
||||
global $mdb, $lang, $settings;
|
||||
|
||||
if ( !$mdb -> get( 'globelus_users', 'visible_mail', [ 'id' => $user_id ] ) and $email )
|
||||
{
|
||||
$text = $settings['newsletter_header'];
|
||||
$text .= \front\factory\Newsletter::get_template( '#twoj-profil-jest-juz-widoczny' );
|
||||
|
||||
$text .= $settings['newsletter_footer_1'];
|
||||
|
||||
$settings['ssl'] ? $base = 'https' : $base = 'http';
|
||||
|
||||
$regex = "-(<img[^>]+src\s*=\s*['\"])(((?!'|\"|https?://).)*)(['\"][^>]*>)-i";
|
||||
$text = preg_replace( $regex, "$1" . $base . "://" . $_SERVER['SERVER_NAME'] . "$2$4", $text );
|
||||
|
||||
$regex = "-(<a[^>]+href\s*=\s*['\"])(((?!'|\"|https?://).)*)(['\"][^>]*>)-i";
|
||||
$text = preg_replace( $regex, "$1" . $base . "://" . $_SERVER['SERVER_NAME'] . "$2$4", $text );
|
||||
|
||||
$send = \S::send_email( $email, $lang['mail-profil-jest-juz-widoczny'], $text );
|
||||
|
||||
$mdb -> update( 'globelus_users', [ 'visible_mail' => 1 ], [ 'id' => $user_id ] );
|
||||
}
|
||||
return $mdb -> update( 'globelus_users', [
|
||||
'visible' => 1
|
||||
], [
|
||||
'id' => $user_id
|
||||
] );
|
||||
}
|
||||
|
||||
public static function profile_extend( $user_id, $active_to )
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
$active_diff = \S::date_diff( date( 'Y-m-d H:i:s' ), date( 'Y-m-d H:i:s', strtotime( $active_to ) ), 60 * 60 * 24 );
|
||||
if ( $active_diff <= 7 )
|
||||
{
|
||||
$mdb -> update( 'globelus_users', [
|
||||
'active_to' => date( 'Y-m-d', strtotime( '+90 days', strtotime( $active_to ) ) ),
|
||||
'mail_expiration' => 0,
|
||||
'mail_expired' => 0,
|
||||
'mail_delete' => 0,
|
||||
'mail_delete_date' => null,
|
||||
], [
|
||||
'id' => $user_id
|
||||
] );
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function profile_refresh( $user_id, $last_refresh )
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
$refresh_diff = \S::date_diff( date( 'Y-m-d H:i:s', strtotime( $last_refresh ) ), date( 'Y-m-d H:i:s' ), 60 * 60 * 24 );
|
||||
if ( $refresh_diff >= 5 )
|
||||
{
|
||||
$mdb -> update( 'globelus_candidates_data', [
|
||||
'last_refresh' => date( 'Y-m-d H:i:s' )
|
||||
], [
|
||||
'user_id' => $user_id
|
||||
] );
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function datą_save( $user_id, $name, $surname, $date_of_birth, $sex, $phone, $experience_abroad, $status_of_availability, $date_of_availability, $accommodation, $driving_license, $own_car,
|
||||
$positions, $positions_experience, $inexperience, $countries, $voivodeships, $languages, $languages_experience, $other_information, $categories, $cv_file, $avatar_file )
|
||||
{
|
||||
global $mdb, $lang;
|
||||
|
||||
if ( $data_id = $mdb -> get( 'globelus_candidates_data', 'id', [ 'user_id' => $user_id ] ) )
|
||||
$mdb -> update( 'globelus_candidates_data', [
|
||||
'name' => $name,
|
||||
'surname' => $surname,
|
||||
'date_of_birth' => $date_of_birth ? date( 'Y-m-d', strtotime( $date_of_birth ) ) : null,
|
||||
'sex' => $sex === '' ? null : $sex,
|
||||
'phone' => $phone,
|
||||
'experience_abroad' => $experience_abroad === '' ? null : $experience_abroad,
|
||||
'status_of_availability' => $status_of_availability,
|
||||
'date_of_availability' => $date_of_availability,
|
||||
'accommodation' => $accommodation === '' ? null : $accommodation,
|
||||
'driving_license' => $driving_license === '' ? null : $driving_license,
|
||||
'own_car' => $own_car === '' ? null : $own_car,
|
||||
'inexperience' => $inexperience == 'on' ? 1 : 0,
|
||||
'other_information' => $other_information
|
||||
], [
|
||||
'id' => $data_id
|
||||
] );
|
||||
else
|
||||
$mdb -> insert( 'globelus_candidates_data', [
|
||||
'user_id' => $user_id,
|
||||
'name' => $name,
|
||||
'surname' => $surname,
|
||||
'date_of_birth' => $date_of_birth ? date( 'Y-m-d', strtotime( $date_of_birth ) ) : null,
|
||||
'sex' => $sex === '' ? null : $sex,
|
||||
'phone' => $phone,
|
||||
'experience_abroad' => $experience_abroad === '' ? null : $experience_abroad,
|
||||
'status_of_availability' => $status_of_availability,
|
||||
'date_of_availability' => $date_of_availability,
|
||||
'accommodation' => $accommodation === '' ? null : $accommodation,
|
||||
'driving_license' => $driving_license === '' ? null : $driving_license,
|
||||
'own_car' => $own_car === '' ? null : $own_car,
|
||||
'inexperience' => $inexperience == 'on' ? 1 : 0,
|
||||
'other_information' => $other_information
|
||||
] );
|
||||
|
||||
$mdb -> update( 'globelus_users', [ 'profile_completed' => 1 ], [ 'id' => $user_id ] );
|
||||
|
||||
/* doświadczenie */
|
||||
$mdb -> delete( 'globelus_candidates_positions', [ 'user_id' => $user_id ] );
|
||||
if ( !$inexperience )
|
||||
{
|
||||
for ( $i = 0; $i < count( $positions ); $i++ )
|
||||
{
|
||||
if ( $positions[$i] )
|
||||
$mdb -> insert( 'globelus_candidates_positions', [
|
||||
'user_id' => $user_id,
|
||||
'id_position' => $positions[$i],
|
||||
'experience' => $positions_experience[$i]
|
||||
] );
|
||||
}
|
||||
}
|
||||
|
||||
/* języki */
|
||||
$mdb -> delete( 'globelus_candidates_languages', [ 'user_id' => $user_id ] );
|
||||
for ( $i = 0; $i < count( $languages ); $i++ )
|
||||
{
|
||||
if ( $languages[$i] and $languages_experience[$i] )
|
||||
$mdb -> insert( 'globelus_candidates_languages', [
|
||||
'user_id' => $user_id,
|
||||
'language' => $languages[$i],
|
||||
'experience' => $languages_experience[$i]
|
||||
] );
|
||||
}
|
||||
|
||||
/* kraje */
|
||||
$not_in = '0';
|
||||
if ( is_array( $countries ) and !empty( $countries ) ) foreach ( $countries as $country )
|
||||
{
|
||||
$not_in .= ',' . (int)$country;
|
||||
}
|
||||
|
||||
$mdb -> query( 'DELETE FROM globelus_candidates_countries WHERE user_id = ' . (int)$user_id . ' AND country_id NOT IN (' . $not_in . ')' );
|
||||
for ( $i = 0; $i < count( $countries ); $i++ )
|
||||
{
|
||||
if ( $countries[$i] and !$mdb -> count( 'globelus_candidates_countries', [ 'AND' => [ 'user_id' => $user_id, 'country_id' => $countries[$i] ] ] ) )
|
||||
$mdb -> insert( 'globelus_candidates_countries', [
|
||||
'user_id' => $user_id,
|
||||
'country_id' => $countries[$i],
|
||||
] );
|
||||
}
|
||||
|
||||
/* województwa */
|
||||
$not_in = '0';
|
||||
if ( is_array( $voivodeships ) and !empty( $voivodeships ) ) foreach ( $voivodeships as $voivodeship )
|
||||
{
|
||||
$not_in .= ',' . (int)$voivodeship;
|
||||
}
|
||||
|
||||
$mdb -> query( 'DELETE FROM globelus_candidates_voivodeships WHERE id_user = ' . (int)$user_id . ' AND id_voivodeship NOT IN (' . $not_in . ')' );
|
||||
for ( $i = 0; $i < count( $voivodeships ); $i++ )
|
||||
{
|
||||
if ( $voivodeships[$i] and !$mdb -> count( 'globelus_candidates_voivodeships', [ 'AND' => [ 'id_user' => $user_id, 'id_voivodeship' => $voivodeships[$i] ] ] ) )
|
||||
$mdb -> insert( 'globelus_candidates_voivodeships', [
|
||||
'id_user' => $user_id,
|
||||
'id_voivodeship' => $voivodeships[$i],
|
||||
] );
|
||||
}
|
||||
|
||||
/* branże */
|
||||
$not_in = '0';
|
||||
if ( is_array( $categories ) and !empty( $categories ) ) foreach ( $categories as $category )
|
||||
{
|
||||
$not_in .= ',' . (int)$category;
|
||||
}
|
||||
|
||||
$mdb -> query( 'DELETE FROM globelus_candidates_categories WHERE user_id = ' . (int)$user_id . ' AND category_id NOT IN (' . $not_in . ')' );
|
||||
for ( $i = 0; $i < count( $categories ); $i++ )
|
||||
{
|
||||
if ( $categories[$i] and !$mdb -> count( 'globelus_candidates_categories', [ 'AND' => [ 'user_id' => $user_id, 'category_id' => $categories[$i] ] ] ) )
|
||||
$mdb -> insert( 'globelus_candidates_categories', [
|
||||
'user_id' => $user_id,
|
||||
'category_id' => $categories[$i],
|
||||
] );
|
||||
}
|
||||
|
||||
/* obsługa plików CV */
|
||||
$allowed_mime_types = \front\factory\Globelus::cv_allowed_mime_types();
|
||||
|
||||
$cv_error = false;
|
||||
|
||||
if ( $cv_file['tmp_name'] and $cv_file["size"] > 5242880 )
|
||||
{
|
||||
\S::set_alert_prompt( 'Informacja', $lang['plik-cv-jest-zbyt-duzy'] );
|
||||
$cv_error = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( $cv_file['tmp_name'] and !$cv_error and !in_array( $cv_file["type"], $allowed_mime_types ) )
|
||||
{
|
||||
\S::set_alert_prompt( 'Informacja', $lang['cv-niedozwolony-format-pliku'] );
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( $cv_file['tmp_name'] and !$cv_error )
|
||||
{
|
||||
$cv_hash = \front\factory\GlobelusCandidates::cv_hash( $user_id );
|
||||
$dir = 'files/cv/' . $cv_hash{0} . '/' . $cv_hash{1} . '/';
|
||||
|
||||
if ( !is_dir( $dir ) )
|
||||
mkdir( $dir , 0755 , true );
|
||||
|
||||
$info = new \SplFileInfo( $cv_file['name'] );
|
||||
$file_ext = $info -> getExtension();
|
||||
|
||||
move_uploaded_file( $cv_file['tmp_name'], $dir . $cv_hash );
|
||||
|
||||
$mdb -> update( 'globelus_candidates_data', [ 'cv_extension' => $file_ext ], [ 'user_id' => $user_id ] );
|
||||
}
|
||||
|
||||
/* obsługa avatarów */
|
||||
$allowed_mime_types = \front\factory\Globelus::avatar_allowed_mime_types();
|
||||
|
||||
$avatar_error = false;
|
||||
|
||||
if ( $avatar_file['tmp_name'] and $avatar_file["size"] > 1048576 )
|
||||
{
|
||||
\S::set_alert_prompt( 'Informacja', $lang['plik-zdjecie-jest-zbyt-duzy'] );
|
||||
$avatar_error = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( $avatar_file['tmp_name'] and !$avatar_error and !in_array( $avatar_file["type"], $allowed_mime_types ) )
|
||||
{
|
||||
\S::set_alert_prompt( 'Informacja', $lang['zdjecie-niedozwolony-format-pliku'] );
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( $avatar_file['tmp_name'] and !$avatar_error )
|
||||
{
|
||||
$avatar_hash = \front\factory\GlobelusCandidates::avatar_hash( $user_id );
|
||||
$dir = 'files/avatars/' . $avatar_hash{0} . '/' . $avatar_hash{1} . '/';
|
||||
|
||||
if ( !is_dir( $dir ) )
|
||||
mkdir( $dir , 0755 , true );
|
||||
|
||||
$info = new \SplFileInfo( $avatar_file['name'] );
|
||||
$file_ext = $info -> getExtension();
|
||||
|
||||
move_uploaded_file( $avatar_file['tmp_name'], $dir . $avatar_hash );
|
||||
|
||||
$mdb -> update( 'globelus_candidates_data', [ 'avatar_extension' => $file_ext ], [ 'user_id' => $user_id ] );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
506
autoload/front/factory/class.GlobelusCron.php
Normal file
506
autoload/front/factory/class.GlobelusCron.php
Normal file
@@ -0,0 +1,506 @@
|
||||
<?php
|
||||
namespace front\factory;
|
||||
class GlobelusCron
|
||||
{
|
||||
static public function fill_proposed_candidates()
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
// usuń starych proponowanych kandydatów
|
||||
$mdb -> delete( 'globelus_proposed_candidates', [ 'date_add[<=]' => date( 'Y-m-d', strtotime( '-30 days', time() ) ) ] );
|
||||
|
||||
// pobierz wszystkie aktywne ogłoszenia z przypisanymi kandydatami i przypisanem krajem
|
||||
$adverts = $mdb -> query( 'SELECT ga.id, id_position, country_id, title FROM globelus_adverts AS ga WHERE visible = 1 AND id_position IS NOT NULL AND country_id IS NOT NULL AND ( ga.proposed_candidates_date IS NULL OR ga.proposed_candidates_date <= \'' . date( 'Y-m-d H:i:s', strtotime( '-1 days', time() ) ) . '\' ) ORDER BY proposed_candidates_date ASC, id ASC LIMIT 10' ) -> fetchAll( \PDO::FETCH_ASSOC );
|
||||
|
||||
if ( is_array( $adverts ) ) foreach ( $adverts as $advert )
|
||||
{
|
||||
$candidates_ids = $mdb -> select( 'globelus_candidates_positions', 'user_id', [ 'id_position' => $advert['id_position'] ] );
|
||||
|
||||
$candidates_ids = $mdb -> query( 'SELECT gu.id FROM globelus_users AS gu WHERE type = 0 AND status = 1 AND visible = 1 AND active_to >= \'' . date( "Y-m-d" ) . '\' AND gu.id IN ( ' . implode( ',', array_merge( [0], $candidates_ids ) ) . ')' ) -> fetchAll( \PDO::FETCH_ASSOC );
|
||||
if ( is_array( $candidates_ids ) ) foreach ( $candidates_ids as $candidate )
|
||||
{
|
||||
if ( !$mdb -> count( 'globelus_proposed_candidates', [ 'AND' => [ 'advert_id' => $advert['id'], 'candidate_id' => $candidate['id'] ] ] ) )
|
||||
{
|
||||
if ( $mdb -> count( 'globelus_candidates_countries', [ 'AND' => [ 'user_id' => $candidate['id'], 'country_id' => $advert['country_id'] ] ] ) )
|
||||
$mdb -> insert( 'globelus_proposed_candidates', [ 'advert_id' => $advert['id'], 'candidate_id' => $candidate['id'], 'date_add' => date( 'Y-m-d H:i:s' ) ] );
|
||||
}
|
||||
}
|
||||
|
||||
$mdb -> update( 'globelus_adverts', [ 'proposed_candidates_date' => date( 'Y-m-d H:i:s' ) ], [ 'id' => $advert['id'] ] );
|
||||
|
||||
echo( '<p>Wyszukuję proponowanych kandydatów dla ogłoszenia: <b>' . $advert['title'] . '</b> #' . $advert['id'] . '</p>' );
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function disable_cv_access()
|
||||
{
|
||||
global $mdb, $settings;
|
||||
|
||||
$results = $mdb -> query( 'SELECT '
|
||||
. 'gu.id '
|
||||
. 'FROM '
|
||||
. 'globelus_users AS gu '
|
||||
. 'WHERE '
|
||||
. 'gu.cv_access_date < \'' . date( 'Y-m-d' ) . '\' '
|
||||
. 'LIMIT 10' ) -> fetchAll( \PDO::FETCH_ASSOC );
|
||||
if ( is_array( $results ) and !empty( $results ) ) foreach ( $results as $row )
|
||||
{
|
||||
$mdb -> update( 'globelus_users', [
|
||||
'cv_access' => 0,
|
||||
'cv_access_date' => null
|
||||
], [
|
||||
'id' => $row['id']
|
||||
] );
|
||||
$mdb -> delete( 'globelus_firms_categories', [ 'user_id' => $row['id'] ] );
|
||||
echo( '<p>Wyłączam dostęp do CV.</p>' );
|
||||
}
|
||||
}
|
||||
|
||||
public static function nopl()
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
$results = $mdb -> query( 'SELECT id, title FROM globelus_adverts WHERE title_nopl IS NULL' ) -> fetchAll( \PDO::FETCH_ASSOC );
|
||||
if ( is_array( $results ) and !empty( $results ) ) foreach ( $results as $row )
|
||||
{
|
||||
$mdb -> update( 'globelus_adverts', [ 'title_nopl' => \S::seo( $row['title'], true ) ], [ 'id' => $row['id'] ] );
|
||||
echo( '<p>Generuje wartość nopl - ogłoszenia.</p>' );
|
||||
}
|
||||
|
||||
$results = $mdb -> query( 'SELECT id, firm_name_profile FROM globelus_firms_data WHERE firm_name_profile_nopl IS NULL' ) -> fetchAll( \PDO::FETCH_ASSOC );
|
||||
if ( is_array( $results ) and !empty( $results ) ) foreach ( $results as $row )
|
||||
{
|
||||
$mdb -> update( 'globelus_firms_data', [ 'firm_name_profile_nopl' => \S::seo( $row['firm_name_profile'], true ) ], [ 'id' => $row['id'] ] );
|
||||
echo( '<p>Generuje wartość nopl - firmy.</p>' );
|
||||
}
|
||||
|
||||
$results = $mdb -> query( 'SELECT id, text FROM globelus_adverts WHERE text_nopl IS NULL' ) -> fetchAll( \PDO::FETCH_ASSOC );
|
||||
if ( is_array( $results ) and !empty( $results ) ) foreach ( $results as $row )
|
||||
{
|
||||
$mdb -> update( 'globelus_adverts', [ 'text_nopl' => \S::seo( $row['text'], true ) ], [ 'id' => $row['id'] ] );
|
||||
echo( '<p>Generuje wartość nopl - ogłoszenia.</p>' );
|
||||
}
|
||||
|
||||
$results = $mdb -> query( 'SELECT id, name FROM globelus_countries WHERE name_nopl IS NULL' ) -> fetchAll( \PDO::FETCH_ASSOC );
|
||||
if ( is_array( $results ) and !empty( $results ) ) foreach ( $results as $row )
|
||||
{
|
||||
$mdb -> update( 'globelus_countries', [ 'name_nopl' => \S::seo( $row['name'], true ) ], [ 'id' => $row['id'] ] );
|
||||
echo( '<p>Generuje wartość nopl - kraje.</p>' );
|
||||
}
|
||||
|
||||
$results = $mdb -> query( 'SELECT id, city FROM globelus_adverts WHERE city_nopl IS NULL' ) -> fetchAll( \PDO::FETCH_ASSOC );
|
||||
if ( is_array( $results ) and !empty( $results ) ) foreach ( $results as $row )
|
||||
{
|
||||
$mdb -> update( 'globelus_adverts', [ 'city_nopl' => \S::seo( $row['city'], true ) ], [ 'id' => $row['id'] ] );
|
||||
echo( '<p>Generuje wartość nopl - miasta.</p>' );
|
||||
}
|
||||
|
||||
$results = $mdb -> query( 'SELECT id, name FROM globelus_adverts_categories WHERE name_seo IS NULL' ) -> fetchAll( \PDO::FETCH_ASSOC );
|
||||
if ( is_array( $results ) and !empty( $results ) ) foreach ( $results as $row )
|
||||
{
|
||||
$mdb -> update( 'globelus_adverts_categories', [ 'name_seo' => \S::seo( $row['name'], true ) ], [ 'id' => $row['id'] ] );
|
||||
echo( '<p>Generuje wartość nopl - kategorie.</p>' );
|
||||
}
|
||||
}
|
||||
|
||||
public static function disable_old_adverts()
|
||||
{
|
||||
global $mdb, $settings;
|
||||
|
||||
$results = $mdb -> query( 'SELECT '
|
||||
. 'ga.id, gu.email, ga.title, ga.date_add '
|
||||
. 'FROM '
|
||||
. 'globelus_adverts AS ga '
|
||||
. 'INNER JOIN globelus_users AS gu ON gu.id = ga.user_id '
|
||||
. 'WHERE '
|
||||
. 'ga.active_to < \'' . date( "Y-m-d" ) . '\' '
|
||||
. 'AND '
|
||||
. '( old = 0 OR ga.visible = 1 )' ) -> fetchAll( \PDO::FETCH_ASSOC );
|
||||
if ( is_array( $results ) and !empty( $results ) ) foreach ( $results as $row )
|
||||
{
|
||||
$mdb -> update( 'globelus_adverts', [
|
||||
'visible' => 0,
|
||||
'active_to' => null,
|
||||
'highlight' => 0,
|
||||
'highlight_to' => null,
|
||||
'main_page' => 0,
|
||||
'main_page_to' => null,
|
||||
'old' => 1,
|
||||
'last_refresh' => null
|
||||
], [
|
||||
'id' => $row['id']
|
||||
] );
|
||||
echo( '<p>Wyłączam stare ogłoszenia.</p>' );
|
||||
}
|
||||
}
|
||||
|
||||
public static function disable_adverts_main_page()
|
||||
{
|
||||
global $mdb, $lang, $settings;
|
||||
|
||||
$results = $mdb -> query( 'SELECT '
|
||||
. 'ga.id, gu.email, ga.title '
|
||||
. 'FROM '
|
||||
. 'globelus_adverts AS ga '
|
||||
. 'INNER JOIN globelus_users AS gu ON gu.id = ga.user_id '
|
||||
. 'WHERE '
|
||||
. 'ga.main_page_to < \'' . date( 'Y-m-d' ) . '\' '
|
||||
. 'LIMIT 10' ) -> fetchAll( \PDO::FETCH_ASSOC );
|
||||
if ( is_array( $results ) ) foreach ( $results as $row )
|
||||
{
|
||||
$days = \S::date_diff( date( 'Y-m-d' ), $row['active_to'], 60 * 60 * 24 );
|
||||
|
||||
$text = $settings['newsletter_header'];
|
||||
$text .= \front\factory\Newsletter::get_template( '#koniec-polecania-ogloszenia' );
|
||||
|
||||
$text .= $settings['newsletter_footer_1'];
|
||||
|
||||
$settings['ssl'] ? $base = 'https' : $base = 'http';
|
||||
|
||||
$regex = "-(<img[^>]+src\s*=\s*['\"])(((?!'|\"|https?://).)*)(['\"][^>]*>)-i";
|
||||
$text = preg_replace( $regex, "$1" . $base . "://" . $_SERVER['SERVER_NAME'] . "$2$4", $text );
|
||||
|
||||
$regex = "-(<a[^>]+href\s*=\s*['\"])(((?!'|\"|https?://).)*)(['\"][^>]*>)-i";
|
||||
$text = preg_replace( $regex, "$1" . $base . "://" . $_SERVER['SERVER_NAME'] . "$2$4", $text );
|
||||
|
||||
$text = str_replace( '[X]', $days, $text );
|
||||
$text = str_replace( '[TYTUL]', $row['title'], $text );
|
||||
|
||||
//$send = \S::send_email( $row['email'], str_replace( '[TYTUL]', $row['title'], $lang['mail-ogloszenie-koniec-polecania'] ), $text );
|
||||
|
||||
$mdb -> update( 'globelus_adverts', [ 'main_page' => 0, 'main_page_to' => null ], [ 'id' => $row['id'] ] );
|
||||
|
||||
echo( '<p>Wysyłam powiadomienie o końcu polecania ogłoszenia.</p>' );
|
||||
}
|
||||
}
|
||||
|
||||
public static function disable_adverts_highlights()
|
||||
{
|
||||
global $mdb, $lang, $settings, $globelus_settings;
|
||||
|
||||
$results = $mdb -> query( 'SELECT '
|
||||
. 'ga.id, gu.email, ga.title '
|
||||
. 'FROM '
|
||||
. 'globelus_adverts AS ga '
|
||||
. 'INNER JOIN globelus_users AS gu ON gu.id = ga.user_id '
|
||||
. 'WHERE '
|
||||
. 'ga.highlight_to < \'' . date( 'Y-m-d' ) . '\' '
|
||||
. 'LIMIT 10' ) -> fetchAll( \PDO::FETCH_ASSOC );
|
||||
if ( is_array( $results ) ) foreach ( $results as $row )
|
||||
{
|
||||
$days = \S::date_diff( date( 'Y-m-d' ), $row['active_to'], 60 * 60 * 24 );
|
||||
|
||||
$text = $settings['newsletter_header'];
|
||||
$text .= \front\factory\Newsletter::get_template( '#koniec-wyroznienia-ogloszenia' );
|
||||
|
||||
$text .= $settings['newsletter_footer_1'];
|
||||
|
||||
$settings['ssl'] ? $base = 'https' : $base = 'http';
|
||||
|
||||
$regex = "-(<img[^>]+src\s*=\s*['\"])(((?!'|\"|https?://).)*)(['\"][^>]*>)-i";
|
||||
$text = preg_replace( $regex, "$1" . $base . "://" . $_SERVER['SERVER_NAME'] . "$2$4", $text );
|
||||
|
||||
$regex = "-(<a[^>]+href\s*=\s*['\"])(((?!'|\"|https?://).)*)(['\"][^>]*>)-i";
|
||||
$text = preg_replace( $regex, "$1" . $base . "://" . $_SERVER['SERVER_NAME'] . "$2$4", $text );
|
||||
|
||||
$text = str_replace( '[X]', $days, $text );
|
||||
$text = str_replace( '[TYTUL]', $row['title'], $text );
|
||||
|
||||
//$send = \S::send_email( $row['email'], str_replace( '[TYTUL]', $row['title'], $lang['mail-ogloszenie-koniec-wyroznienia'] ), $text );
|
||||
|
||||
$mdb -> update( 'globelus_adverts', [ 'highlight' => 0, 'highlight_to' => null ], [ 'id' => $row['id'] ] );
|
||||
|
||||
echo( '<p>Wysyłam powiadomienie o końcu wyróżnienia ogłoszenia.</p>' );
|
||||
}
|
||||
}
|
||||
|
||||
public static function disable_profile_highlights()
|
||||
{
|
||||
global $mdb, $lang, $settings;
|
||||
|
||||
$results = $mdb -> query( 'SELECT '
|
||||
. 'gu.id, gu.email '
|
||||
. 'FROM '
|
||||
. 'globelus_users AS gu '
|
||||
. 'WHERE '
|
||||
. 'gu.highlight_to < \'' . date( 'Y-m-d' ) . '\' '
|
||||
. 'LIMIT 10' ) -> fetchAll( \PDO::FETCH_ASSOC );
|
||||
if ( is_array( $results ) ) foreach ( $results as $row )
|
||||
{
|
||||
$mdb -> update( 'globelus_users', [ 'highlight' => 0, 'highlight_to' => null ], [ 'id' => $row['id'] ] );
|
||||
|
||||
echo( '<p>Wyłączam wyróżnione profile.</p>' );
|
||||
}
|
||||
}
|
||||
|
||||
public static function email_advert_expired()
|
||||
{
|
||||
global $mdb, $lang, $settings, $globelus_settings;
|
||||
|
||||
$results = $mdb -> query( 'SELECT '
|
||||
. 'ga.id, ga.active_to, gu.email, ga.title '
|
||||
. 'FROM '
|
||||
. 'globelus_adverts AS ga '
|
||||
. 'INNER JOIN globelus_users AS gu ON gu.id = ga.user_id '
|
||||
. 'WHERE '
|
||||
. 'ga.visible = 1 '
|
||||
. 'AND '
|
||||
. 'ga.active_to IS NOT NULL '
|
||||
. 'AND '
|
||||
. 'ga.active_to < \'' . date( 'Y-m-d' ) . '\' '
|
||||
. 'AND '
|
||||
. 'ga.mail_expired = 0 '
|
||||
. 'LIMIT 10' ) -> fetchAll( \PDO::FETCH_ASSOC );
|
||||
if ( is_array( $results ) ) foreach ( $results as $row )
|
||||
{
|
||||
$days = \S::date_diff( date( 'Y-m-d' ), $row['active_to'], 60 * 60 * 24 );
|
||||
|
||||
$text = $settings['newsletter_header'];
|
||||
$text .= \front\factory\Newsletter::get_template( '#ogloszenie-wygaslo' );
|
||||
|
||||
$text .= $settings['newsletter_footer_1'];
|
||||
|
||||
$settings['ssl'] ? $base = 'https' : $base = 'http';
|
||||
|
||||
$regex = "-(<img[^>]+src\s*=\s*['\"])(((?!'|\"|https?://).)*)(['\"][^>]*>)-i";
|
||||
$text = preg_replace( $regex, "$1" . $base . "://" . $_SERVER['SERVER_NAME'] . "$2$4", $text );
|
||||
|
||||
$regex = "-(<a[^>]+href\s*=\s*['\"])(((?!'|\"|https?://).)*)(['\"][^>]*>)-i";
|
||||
$text = preg_replace( $regex, "$1" . $base . "://" . $_SERVER['SERVER_NAME'] . "$2$4", $text );
|
||||
|
||||
$text = str_replace( '[X]', $days, $text );
|
||||
$text = str_replace( '[TYTUL]', $row['title'], $text );
|
||||
|
||||
// if ( $globelus_settings['maile-wysylanie'] )
|
||||
// $send = \S::send_email( $row['email'], str_replace( '[TYTUL]', $row['title'], $lang['mail-tytul-ogloszenie-wygaslo'] ), $text );
|
||||
|
||||
$mdb -> update( 'globelus_adverts', [ 'visible' => 0, 'mail_expired' => 1, 'highlight' => 0, 'highlight_to' => null, 'main_page' => 0, 'main_page_to' => null ], [ 'id' => $row['id'] ] );
|
||||
|
||||
echo( '<p>Wysyłam powiadomienie o wygaśnięciu ogłoszenia.</p>' );
|
||||
}
|
||||
}
|
||||
|
||||
public static function delete_inactive_profiles()
|
||||
{
|
||||
global $mdb, $lang, $settings, $globelus_settings;
|
||||
|
||||
$results = $mdb -> query( 'SELECT '
|
||||
. 'gu.id, gu.email '
|
||||
. 'FROM '
|
||||
. 'globelus_users AS gu '
|
||||
. 'WHERE '
|
||||
. 'gu.type = 0 '
|
||||
. 'AND '
|
||||
. 'gu.mail_delete_date < \'' . date( 'Y-m-d', strtotime( '-14 days', time() ) ) . '\' '
|
||||
. 'AND '
|
||||
. 'gu.mail_delete = 1 '
|
||||
. 'LIMIT 1' ) -> fetchAll( \PDO::FETCH_ASSOC );
|
||||
if ( is_array( $results ) ) foreach ( $results as $row )
|
||||
{
|
||||
$text = $settings['newsletter_header'];
|
||||
$text .= \front\factory\Newsletter::get_template( '#kandydat-usuniecie-konta-kandydata' );
|
||||
|
||||
$text .= $settings['newsletter_footer_1'];
|
||||
|
||||
$settings['ssl'] ? $base = 'https' : $base = 'http';
|
||||
|
||||
$text = str_replace( '[LINK]', $base . "://" . $_SERVER['SERVER_NAME'] . "/login-as/" . $row['hash'] . "?return_url=" . urlencode( '/panel-pracodawcy/ogloszenia' ), $text );
|
||||
|
||||
$regex = "-(<img[^>]+src\s*=\s*['\"])(((?!'|\"|https?://).)*)(['\"][^>]*>)-i";
|
||||
$text = preg_replace( $regex, "$1" . $base . "://" . $_SERVER['SERVER_NAME'] . "$2$4", $text );
|
||||
|
||||
$regex = "-(<a[^>]+href\s*=\s*['\"])(((?!'|\"|https?://).)*)(['\"][^>]*>)-i";
|
||||
$text = preg_replace( $regex, "$1" . $base . "://" . $_SERVER['SERVER_NAME'] . "$2$4", $text );
|
||||
|
||||
$text = str_replace( '[TYTUL]', $row['title'], $text );
|
||||
|
||||
if ( $globelus_settings['maile-wysylanie'] )
|
||||
$send = \S::send_email( $row['email'], $lang['mail-tytul-konto-kandydata-usuniete'] . $row['title'], $text );
|
||||
|
||||
$mdb -> delete( 'globelus_users', [ 'id' => $row['id'] ] );
|
||||
|
||||
echo( '<p>Usuwanie nieaktywnych kont.</p>' );
|
||||
}
|
||||
}
|
||||
|
||||
public static function email_advert_expiration()
|
||||
{
|
||||
global $mdb, $lang, $settings, $globelus_settings;
|
||||
|
||||
$results = $mdb -> query( 'SELECT '
|
||||
. 'ga.id, ga.active_to, gu.email, ga.title, gu.hash '
|
||||
. 'FROM '
|
||||
. 'globelus_adverts AS ga '
|
||||
. 'INNER JOIN globelus_users AS gu ON gu.id = ga.user_id '
|
||||
. 'WHERE '
|
||||
. 'ga.visible = 1 '
|
||||
. 'AND '
|
||||
. 'ga.active_to IS NOT NULL '
|
||||
. 'AND '
|
||||
. 'ga.active_to <= \'' . date( 'Y-m-d', strtotime( '+3 days', time() ) ) . '\' '
|
||||
. 'AND '
|
||||
. 'ga.mail_expiration = 0 '
|
||||
. 'LIMIT 1' ) -> fetchAll( \PDO::FETCH_ASSOC );
|
||||
if ( is_array( $results ) ) foreach ( $results as $row )
|
||||
{
|
||||
$days = \S::date_diff( date( 'Y-m-d' ), $row['active_to'], 60 * 60 * 24 );
|
||||
|
||||
$text = $settings['newsletter_header'];
|
||||
$text .= \front\factory\Newsletter::get_template( '#przedluz-swoje-ogloszenie' );
|
||||
|
||||
$text .= $settings['newsletter_footer_1'];
|
||||
|
||||
$settings['ssl'] ? $base = 'https' : $base = 'http';
|
||||
|
||||
$text = str_replace( '[LINK]', $base . "://" . $_SERVER['SERVER_NAME'] . "/login-as/" . $row['hash'] . "?return_url=" . urlencode( '/panel-pracodawcy/ogloszenia' ), $text );
|
||||
|
||||
$regex = "-(<img[^>]+src\s*=\s*['\"])(((?!'|\"|https?://).)*)(['\"][^>]*>)-i";
|
||||
$text = preg_replace( $regex, "$1" . $base . "://" . $_SERVER['SERVER_NAME'] . "$2$4", $text );
|
||||
|
||||
$regex = "-(<a[^>]+href\s*=\s*['\"])(((?!'|\"|https?://).)*)(['\"][^>]*>)-i";
|
||||
$text = preg_replace( $regex, "$1" . $base . "://" . $_SERVER['SERVER_NAME'] . "$2$4", $text );
|
||||
|
||||
$text = str_replace( '[X]', $days, $text );
|
||||
$text = str_replace( '[TYTUL]', $row['title'], $text );
|
||||
|
||||
if ( $globelus_settings['maile-wysylanie'] )
|
||||
$send = \S::send_email( $row['email'], $lang['mail-tytul-ogloszenie-wygasa'] . $row['title'] . '!', $text );
|
||||
|
||||
$mdb -> update( 'globelus_adverts', [ 'mail_expiration' => 1 ], [ 'id' => $row['id'] ] );
|
||||
|
||||
echo( '<p>Wysyłam powiadomienie o wygasaniu ogłoszenia.</p>' );
|
||||
}
|
||||
}
|
||||
|
||||
static public function email_profile_delete()
|
||||
{
|
||||
global $mdb, $lang, $settings, $globelus_settings;
|
||||
|
||||
$results = $mdb -> query( 'SELECT '
|
||||
. 'gu.id, gu.email, active_to '
|
||||
. 'FROM '
|
||||
. 'globelus_users AS gu '
|
||||
. 'WHERE '
|
||||
. 'type = 0 '
|
||||
. 'AND '
|
||||
. 'DATE_ADD( active_to, INTERVAL 180 day ) < \'' . date( 'Y-m-d' ) . '\' '
|
||||
. 'AND '
|
||||
. 'mail_delete = 0 '
|
||||
. 'LIMIT 1' ) -> fetchAll( \PDO::FETCH_ASSOC );
|
||||
if ( is_array( $results ) ) foreach ( $results as $row )
|
||||
{
|
||||
$days = \S::date_diff( date( 'Y-m-d' ), $row['active_to'], 60 * 60 * 24 );
|
||||
|
||||
$text = $settings['newsletter_header'];
|
||||
$text .= \front\factory\Newsletter::get_template( '#kandydat-powiadomienie-o-usunieciu-konta' );
|
||||
|
||||
$text .= $settings['newsletter_footer_1'];
|
||||
|
||||
$settings['ssl'] ? $base = 'https' : $base = 'http';
|
||||
|
||||
$regex = "-(<img[^>]+src\s*=\s*['\"])(((?!'|\"|https?://).)*)(['\"][^>]*>)-i";
|
||||
$text = preg_replace( $regex, "$1" . $base . "://" . $_SERVER['SERVER_NAME'] . "$2$4", $text );
|
||||
|
||||
$regex = "-(<a[^>]+href\s*=\s*['\"])(((?!'|\"|https?://).)*)(['\"][^>]*>)-i";
|
||||
$text = preg_replace( $regex, "$1" . $base . "://" . $_SERVER['SERVER_NAME'] . "$2$4", $text );
|
||||
|
||||
$text = str_replace( '[X]', $days, $text );
|
||||
|
||||
if ( $globelus_settings['maile-wysylanie'] )
|
||||
{
|
||||
$send = \S::send_email( $row['email'], $lang['mail-tytul-profil-usuniety'], $text );
|
||||
}
|
||||
|
||||
$mdb -> update( 'globelus_users', [ 'mail_delete' => 1, 'mail_delete_date' => date( 'Y-m-d H:i:s' ) ], [ 'id' => $row['id'] ] );
|
||||
|
||||
echo( '<p>Wysyłam powiadomienie o usuniętym profilu.</p>' );
|
||||
}
|
||||
}
|
||||
|
||||
public static function email_profile_expired()
|
||||
{
|
||||
global $mdb, $lang, $settings, $globelus_settings;
|
||||
|
||||
$results = $mdb -> query( 'SELECT '
|
||||
. 'gu.id, gu.email, active_to '
|
||||
. 'FROM '
|
||||
. 'globelus_users AS gu '
|
||||
. 'WHERE '
|
||||
. 'type = 0 '
|
||||
. 'AND '
|
||||
. 'active_to < \'' . date( 'Y-m-d' ) . '\' '
|
||||
. 'AND '
|
||||
. 'mail_expired = 0 '
|
||||
. 'LIMIT 10' ) -> fetchAll( \PDO::FETCH_ASSOC );
|
||||
if ( is_array( $results ) ) foreach ( $results as $row )
|
||||
{
|
||||
$days = \S::date_diff( date( 'Y-m-d' ), $row['active_to'], 60 * 60 * 24 );
|
||||
|
||||
$text = $settings['newsletter_header'];
|
||||
$text .= \front\factory\Newsletter::get_template( '#kandydat-powiadomienie-o-wygasnieciu-profilu' );
|
||||
|
||||
$text .= $settings['newsletter_footer_1'];
|
||||
|
||||
$settings['ssl'] ? $base = 'https' : $base = 'http';
|
||||
|
||||
$regex = "-(<img[^>]+src\s*=\s*['\"])(((?!'|\"|https?://).)*)(['\"][^>]*>)-i";
|
||||
$text = preg_replace( $regex, "$1" . $base . "://" . $_SERVER['SERVER_NAME'] . "$2$4", $text );
|
||||
|
||||
$regex = "-(<a[^>]+href\s*=\s*['\"])(((?!'|\"|https?://).)*)(['\"][^>]*>)-i";
|
||||
$text = preg_replace( $regex, "$1" . $base . "://" . $_SERVER['SERVER_NAME'] . "$2$4", $text );
|
||||
|
||||
$text = str_replace( '[X]', $days, $text );
|
||||
|
||||
if ( $globelus_settings['maile-wysylanie'] )
|
||||
$send = \S::send_email( $row['email'], $lang['mail-tytul-profil-wygasl'], $text );
|
||||
|
||||
$mdb -> update( 'globelus_users', [ 'mail_expired' => 1 ], [ 'id' => $row['id'] ] );
|
||||
|
||||
echo( '<p>Wysyłam powiadomienie o wygaśniętym profilu.</p>' );
|
||||
}
|
||||
}
|
||||
|
||||
public static function email_profile_expiration()
|
||||
{
|
||||
global $mdb, $lang, $settings, $globelus_settings;
|
||||
|
||||
$results = $mdb -> query( 'SELECT '
|
||||
. 'gu.id, gu.email, active_to '
|
||||
. 'FROM '
|
||||
. 'globelus_users AS gu '
|
||||
. 'WHERE '
|
||||
. 'type = 0 '
|
||||
. 'AND '
|
||||
. 'active_to <= \'' . date( 'Y-m-d', strtotime( '+7 days', time() ) ) . '\' '
|
||||
. 'AND '
|
||||
. 'mail_expiration = 0 '
|
||||
. 'LIMIT 10' ) -> fetchAll( \PDO::FETCH_ASSOC );
|
||||
if ( is_array( $results ) ) foreach ( $results as $row )
|
||||
{
|
||||
$days = \S::date_diff( date( 'Y-m-d' ), $row['active_to'], 60 * 60 * 24 );
|
||||
|
||||
$text = $settings['newsletter_header'];
|
||||
$text .= \front\factory\Newsletter::get_template( '#kandydat-powiadomienie-o-wygasaniu-profilu' );
|
||||
|
||||
$text .= $settings['newsletter_footer_1'];
|
||||
|
||||
$settings['ssl'] ? $base = 'https' : $base = 'http';
|
||||
|
||||
$regex = "-(<img[^>]+src\s*=\s*['\"])(((?!'|\"|https?://).)*)(['\"][^>]*>)-i";
|
||||
$text = preg_replace( $regex, "$1" . $base . "://" . $_SERVER['SERVER_NAME'] . "$2$4", $text );
|
||||
|
||||
$regex = "-(<a[^>]+href\s*=\s*['\"])(((?!'|\"|https?://).)*)(['\"][^>]*>)-i";
|
||||
$text = preg_replace( $regex, "$1" . $base . "://" . $_SERVER['SERVER_NAME'] . "$2$4", $text );
|
||||
|
||||
$text = str_replace( '[X]', $days, $text );
|
||||
|
||||
if ( $globelus_settings['maile-wysylanie'] )
|
||||
$send = \S::send_email( $row['email'], $lang['mail-tytul-profil-niedlugo-wygasnie'], $text );
|
||||
|
||||
$mdb -> update( 'globelus_users', [ 'mail_expiration' => 1 ], [ 'id' => $row['id'] ] );
|
||||
|
||||
echo( '<p>Wysyłam powiadomienie o wygasaniu profilu.</p>' );
|
||||
}
|
||||
}
|
||||
}
|
||||
315
autoload/front/factory/class.GlobelusCv.php
Normal file
315
autoload/front/factory/class.GlobelusCv.php
Normal file
@@ -0,0 +1,315 @@
|
||||
<?php
|
||||
namespace front\factory;
|
||||
class GlobelusCv
|
||||
{
|
||||
const cv_list_limit = 10;
|
||||
|
||||
public static function cv_count( $visible_categories, $keyword = '', $countries = '', $availability = '', $categories = '', $voivodeships = '', $id_position = '' )
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
$visible_categories = array_merge( $visible_categories, [ 0 ] );
|
||||
|
||||
if ( $availability )
|
||||
$filtr .= 'AND status_of_availability = ' . (int)$availability . ' ';
|
||||
|
||||
if ( $keyword )
|
||||
$filtr .= 'AND ( '
|
||||
. 'bez_pl_diakrytycznych( LOWER(position) ) LIKE \'%' . strtolower( preg_replace( '/[^\s\p{L}]/u','', \front\factory\Globelus::noPL( $keyword ) ) ) . '%\' '
|
||||
. 'OR '
|
||||
. 'bez_pl_diakrytycznych( LOWER(other_information) ) LIKE \'%' . strtolower( preg_replace( '/[^\s\p{L}]/u','', \front\factory\Globelus::noPL( $keyword ) ) ) . '%\' '
|
||||
. 'OR '
|
||||
. 'bez_pl_diakrytycznych( LOWER(name) ) LIKE \'%' . strtolower( preg_replace( '/[^\s\p{L}]/u','', \front\factory\Globelus::noPL( $keyword ) ) ) . '%\' '
|
||||
. 'OR '
|
||||
. 'bez_pl_diakrytycznych( LOWER(surname) ) LIKE \'%' . strtolower( preg_replace( '/[^\s\p{L}]/u','', \front\factory\Globelus::noPL( $keyword ) ) ) . '%\' '
|
||||
. ') ';
|
||||
|
||||
if ( is_array( $countries ) and count( $countries ) )
|
||||
$filtr .= 'AND gcc1.country_id IN (' . implode( ',', $countries ) . ') ';
|
||||
|
||||
if ( is_array( $categories ) and count( $categories ) )
|
||||
$filtr .= 'AND gcc.category_id IN (' . implode( ',', $categories ) . ') ';
|
||||
|
||||
if ( is_array( $voivodeships ) and count( $voivodeships ) )
|
||||
$filtr .= 'AND gcv.id_voivodeship IN (' . implode( ',', $voivodeships ) . ') ';
|
||||
|
||||
if ( $id_position )
|
||||
$filtr .= 'AND id_position = ' . (int)$id_position . ' ';
|
||||
|
||||
$sql = 'SELECT COUNT(0) FROM ('
|
||||
. 'SELECT '
|
||||
. 'gu.id '
|
||||
. 'FROM '
|
||||
. 'globelus_users AS gu '
|
||||
. 'INNER JOIN globelus_candidates_data AS gcd ON gcd.user_id = gu.id '
|
||||
. 'INNER JOIN globelus_candidates_categories AS gcc ON gcc.user_id = gu.id ';
|
||||
|
||||
if ( is_array( $voivodeships ) and count( $voivodeships ) )
|
||||
$sql .= 'INNER JOIN globelus_candidates_voivodeships AS gcv ON gcv.id_user = gu.id ';
|
||||
|
||||
if ( $id_position )
|
||||
$sql .= 'INNER JOIN globelus_proposed_candidates AS gpc ON gpc.candidate_id = gu.id ';
|
||||
|
||||
$sql .= 'LEFT JOIN globelus_candidates_positions AS gcp ON gcp.user_id = gu.id '
|
||||
. 'LEFT JOIN globelus_candidates_countries as gcc1 ON gcc1.user_id = gu.id '
|
||||
. 'WHERE '
|
||||
. 'gu.type = 0 '
|
||||
. 'AND '
|
||||
. 'gu.status = 1 '
|
||||
. 'AND '
|
||||
. 'gu.profile_completed = 1 '
|
||||
. 'AND '
|
||||
. 'gu.visible = 1 '
|
||||
. 'AND '
|
||||
. 'gu.active_to >= \'' . date( 'Y-m-d' ). '\' '
|
||||
. 'AND '
|
||||
. 'gcc.category_id IN ( 0,' . implode( ',', $visible_categories ) . ') '
|
||||
. $filtr
|
||||
. 'GROUP BY '
|
||||
. 'gu.id ) '
|
||||
. 'AS q1';
|
||||
|
||||
$result = $mdb -> query( $sql ) -> fetch();
|
||||
return $result[0];
|
||||
}
|
||||
|
||||
public static function prev_profile( $user_id, $visible_categories, $keyword = '', $countries = '', $availability = '', $categories = '', $voivodeships = '', $id_position = '' )
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
$visible_categories = array_merge( $visible_categories, [ 0 ] );
|
||||
|
||||
if ( $availability )
|
||||
$filtr .= 'AND status_of_availability = ' . (int)$availability . ' ';
|
||||
|
||||
if ( $keyword )
|
||||
$filtr .= 'AND ( '
|
||||
. 'bez_pl_diakrytycznych( LOWER(position) ) LIKE \'%' . strtolower( preg_replace( '/[^\s\p{L}]/u','', \front\factory\Globelus::noPL( $keyword ) ) ) . '%\' '
|
||||
. 'OR '
|
||||
. 'bez_pl_diakrytycznych( LOWER(other_information) ) LIKE \'%' . strtolower( preg_replace( '/[^\s\p{L}]/u','', \front\factory\Globelus::noPL( $keyword ) ) ) . '%\' '
|
||||
. 'OR '
|
||||
. 'bez_pl_diakrytycznych( LOWER(name) ) LIKE \'%' . strtolower( preg_replace( '/[^\s\p{L}]/u','', \front\factory\Globelus::noPL( $keyword ) ) ) . '%\' '
|
||||
. 'OR '
|
||||
. 'bez_pl_diakrytycznych( LOWER(surname) ) LIKE \'%' . strtolower( preg_replace( '/[^\s\p{L}]/u','', \front\factory\Globelus::noPL( $keyword ) ) ) . '%\' '
|
||||
. ') ';
|
||||
|
||||
if ( is_array( $countries ) and count( $countries ) )
|
||||
$filtr = 'AND gcc1.country_id IN (' . implode( ',', $countries ) . ') ';
|
||||
|
||||
if ( is_array( $categories ) and count( $categories ) )
|
||||
$filtr = 'AND gcc.category_id IN (' . implode( ',', $categories ) . ') ';
|
||||
|
||||
if ( $id_position )
|
||||
$filtr .= 'AND id_position = ' . (int)$id_position . ' ';
|
||||
|
||||
$sql = 'SELECT '
|
||||
. 'gu.id, name, surname, '
|
||||
. 'IF ( gcd.last_refresh IS NULL, register_date, gcd.last_refresh ) AS date_active '
|
||||
. 'FROM '
|
||||
. 'globelus_users AS gu '
|
||||
. 'INNER JOIN globelus_candidates_data AS gcd ON gcd.user_id = gu.id '
|
||||
. 'INNER JOIN globelus_candidates_categories AS gcc ON gcc.user_id = gu.id ';
|
||||
|
||||
if ( $id_position )
|
||||
$sql .= 'INNER JOIN globelus_proposed_candidates AS gpc ON gpc.candidate_id = gu.id ';
|
||||
|
||||
if ( is_array( $voivodeships ) and count( $voivodeships ) )
|
||||
$sql .= 'INNER JOIN globelus_candidates_voivodeships AS gcv ON gcv.id_user = gu.id ';
|
||||
|
||||
$sql .= 'LEFT JOIN globelus_candidates_positions AS gcp ON gcp.user_id = gu.id '
|
||||
. 'LEFT JOIN globelus_candidates_countries as gcc1 ON gcc1.user_id = gu.id '
|
||||
. 'WHERE '
|
||||
. 'gu.type = 0 '
|
||||
. 'AND '
|
||||
. 'gu.status = 1 '
|
||||
. 'AND '
|
||||
. 'gu.profile_completed = 1 '
|
||||
. 'AND '
|
||||
. 'gu.visible = 1 '
|
||||
. 'AND '
|
||||
. 'gu.active_to >= \'' . date( 'Y-m-d' ). '\' '
|
||||
. 'AND '
|
||||
. 'gcc.category_id IN ( 0,' . implode( ',', $visible_categories ) . ') '
|
||||
. $filtr
|
||||
. 'GROUP BY '
|
||||
. 'gu.id '
|
||||
. 'ORDER BY '
|
||||
. 'highlight DESC, date_active DESC';
|
||||
|
||||
$results = $mdb -> query( $sql ) -> fetchAll( \PDO::FETCH_ASSOC );
|
||||
if ( is_array( $results ) and count( $results ) )
|
||||
{
|
||||
for ( $i = 0; $i < count( $results ); $i++ )
|
||||
{
|
||||
if ( $results[$i]['id'] == $user_id and isset( $results[$i-1]['id'] ) )
|
||||
return '/kandydat/' . $results[$i-1]['id'] . '/' . \S::seo( $results[$i-1]['surname'] . ' ' . $results[$i-1]['name'] );
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function next_profile( $user_id, $visible_categories, $keyword = '', $countries = '', $availability = '', $categories = '', $voivodeships = '', $id_position = '' )
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
$visible_categories = array_merge( $visible_categories, [ 0 ] );
|
||||
|
||||
if ( $availability )
|
||||
$filtr .= 'AND status_of_availability = ' . (int)$availability . ' ';
|
||||
|
||||
if ( $keyword )
|
||||
$filtr .= 'AND ( '
|
||||
. 'bez_pl_diakrytycznych( LOWER(position) ) LIKE \'%' . strtolower( preg_replace( '/[^\s\p{L}]/u','', \front\factory\Globelus::noPL( $keyword ) ) ) . '%\' '
|
||||
. 'OR '
|
||||
. 'bez_pl_diakrytycznych( LOWER(other_information) ) LIKE \'%' . strtolower( preg_replace( '/[^\s\p{L}]/u','', \front\factory\Globelus::noPL( $keyword ) ) ) . '%\' '
|
||||
. 'OR '
|
||||
. 'bez_pl_diakrytycznych( LOWER(name) ) LIKE \'%' . strtolower( preg_replace( '/[^\s\p{L}]/u','', \front\factory\Globelus::noPL( $keyword ) ) ) . '%\' '
|
||||
. 'OR '
|
||||
. 'bez_pl_diakrytycznych( LOWER(surname) ) LIKE \'%' . strtolower( preg_replace( '/[^\s\p{L}]/u','', \front\factory\Globelus::noPL( $keyword ) ) ) . '%\' '
|
||||
. ') ';
|
||||
|
||||
if ( is_array( $countries ) and count( $countries ) )
|
||||
$filtr .= 'AND gcc1.country_id IN (' . implode( ',', $countries ) . ') ';
|
||||
|
||||
if ( is_array( $categories ) and count( $categories ) )
|
||||
$filtr .= 'AND gcc.category_id IN (' . implode( ',', $categories ) . ') ';
|
||||
|
||||
if ( is_array( $voivodeships ) and count( $voivodeships ) )
|
||||
$filtr .= 'AND gcv.id_voivodeship IN (' . implode( ',', $voivodeships ) . ') ';
|
||||
|
||||
if ( $id_position )
|
||||
$filtr .= 'AND id_position = ' . (int)$id_position . ' ';
|
||||
|
||||
$sql = 'SELECT '
|
||||
. 'gu.id, name, surname, '
|
||||
. 'IF ( gcd.last_refresh IS NULL, register_date, gcd.last_refresh ) AS date_active '
|
||||
. 'FROM '
|
||||
. 'globelus_users AS gu '
|
||||
. 'INNER JOIN globelus_candidates_data AS gcd ON gcd.user_id = gu.id '
|
||||
. 'INNER JOIN globelus_candidates_categories AS gcc ON gcc.user_id = gu.id ';
|
||||
|
||||
if ( is_array( $voivodeships ) and count( $voivodeships ) )
|
||||
$sql .= 'INNER JOIN globelus_candidates_voivodeships AS gcv ON gcv.id_user = gu.id ';
|
||||
|
||||
if ( $id_position )
|
||||
$sql .= 'INNER JOIN globelus_proposed_candidates AS gpc ON gpc.candidate_id = gu.id ';
|
||||
|
||||
$sql .= 'LEFT JOIN globelus_candidates_positions AS gcp ON gcp.user_id = gu.id '
|
||||
. 'LEFT JOIN globelus_candidates_countries as gcc1 ON gcc1.user_id = gu.id '
|
||||
. 'WHERE '
|
||||
. 'gu.type = 0 '
|
||||
. 'AND '
|
||||
. 'gu.status = 1 '
|
||||
. 'AND '
|
||||
. 'gu.profile_completed = 1 '
|
||||
. 'AND '
|
||||
. 'gu.visible = 1 '
|
||||
. 'AND '
|
||||
. 'gu.active_to >= \'' . date( 'Y-m-d' ). '\' '
|
||||
. 'AND '
|
||||
. 'gcc.category_id IN ( 0,' . implode( ',', $visible_categories ) . ') '
|
||||
. $filtr
|
||||
. 'GROUP BY '
|
||||
. 'gu.id '
|
||||
. 'ORDER BY '
|
||||
. 'highlight DESC, date_active DESC';
|
||||
|
||||
$results = $mdb -> query( $sql ) -> fetchAll( \PDO::FETCH_ASSOC );
|
||||
if ( is_array( $results ) and count( $results ) )
|
||||
{
|
||||
for ( $i = 0; $i < count( $results ); $i++ )
|
||||
{
|
||||
if ( $results[$i]['id'] == $user_id and isset( $results[$i+1]['id'] ) )
|
||||
return '/kandydat/' . $results[$i+1]['id'] . '/' . \S::seo( $results[$i+1]['surname'] . ' ' . $results[$i+1]['name'] );
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function cv_list( $start = 0, $limit = 2, $visible_categories, $keyword = '', $countries = '', $availability = '', $categories = '', $voivodeships = '', $id_position = '' )
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
$visible_categories = array_merge( $visible_categories, [ 0 ] );
|
||||
|
||||
if ( $start < 1 )
|
||||
$start = 0;
|
||||
else
|
||||
$start--;
|
||||
|
||||
if ( $availability )
|
||||
$filtr .= 'AND status_of_availability = ' . (int)$availability . ' ';
|
||||
|
||||
if ( $keyword )
|
||||
$filtr .= 'AND ( '
|
||||
. 'bez_pl_diakrytycznych( LOWER(position) ) LIKE \'%' . strtolower( preg_replace( '/[^\s\p{L}]/u','', \front\factory\Globelus::noPL( $keyword ) ) ) . '%\' '
|
||||
. 'OR '
|
||||
. 'bez_pl_diakrytycznych( LOWER(other_information) ) LIKE \'%' . strtolower( preg_replace( '/[^\s\p{L}]/u','', \front\factory\Globelus::noPL( $keyword ) ) ) . '%\' '
|
||||
. 'OR '
|
||||
. 'bez_pl_diakrytycznych( LOWER(name) ) LIKE \'%' . strtolower( preg_replace( '/[^\s\p{L}]/u','', \front\factory\Globelus::noPL( $keyword ) ) ) . '%\' '
|
||||
. 'OR '
|
||||
. 'bez_pl_diakrytycznych( LOWER(surname) ) LIKE \'%' . strtolower( preg_replace( '/[^\s\p{L}]/u','', \front\factory\Globelus::noPL( $keyword ) ) ) . '%\' '
|
||||
. ') ';
|
||||
|
||||
if ( is_array( $countries ) and count( $countries ) )
|
||||
$filtr = 'AND gcc1.country_id IN (' . implode( ',', $countries ) . ') ';
|
||||
|
||||
if ( is_array( $categories ) and count( $categories ) )
|
||||
$filtr = 'AND gcc.category_id IN (' . implode( ',', $categories ) . ') ';
|
||||
|
||||
if ( is_array( $voivodeships ) and count( $voivodeships ) )
|
||||
$filtr = 'AND gcv.id_voivodeship IN (' . implode( ',', $voivodeships ) . ') ';
|
||||
|
||||
if ( $id_position )
|
||||
$filtr .= 'AND id_position = ' . (int)$id_position . ' ';
|
||||
|
||||
$sql = 'SELECT '
|
||||
. 'gu.id, name, surname, phone, email, sex, date_of_birth, highlight, register_date, gcd.last_refresh, ';
|
||||
|
||||
if ( is_array( $voivodeships ) and count( $voivodeships ) )
|
||||
$sql .= 'id_voivodeship, ';
|
||||
|
||||
$sql .= 'IF ( gcd.last_refresh IS NULL, register_date, gcd.last_refresh ) AS date_active '
|
||||
. 'FROM '
|
||||
. 'globelus_users AS gu '
|
||||
. 'INNER JOIN globelus_candidates_data AS gcd ON gcd.user_id = gu.id '
|
||||
. 'INNER JOIN globelus_candidates_categories AS gcc ON gcc.user_id = gu.id ';
|
||||
|
||||
if ( is_array( $voivodeships ) and count( $voivodeships ) )
|
||||
$sql .= 'INNER JOIN globelus_candidates_voivodeships AS gcv ON gcv.id_user = gu.id ';
|
||||
|
||||
if ( $id_position )
|
||||
$sql .= 'INNER JOIN globelus_proposed_candidates AS gpc ON gpc.candidate_id = gu.id ';
|
||||
|
||||
$sql .= 'LEFT JOIN globelus_candidates_positions AS gcp ON gcp.user_id = gu.id '
|
||||
. 'LEFT JOIN globelus_candidates_countries as gcc1 ON gcc1.user_id = gu.id '
|
||||
. 'WHERE '
|
||||
. 'gu.type = 0 '
|
||||
. 'AND '
|
||||
. 'gu.status = 1 '
|
||||
. 'AND '
|
||||
. 'gu.profile_completed = 1 '
|
||||
. 'AND '
|
||||
. 'gu.visible = 1 '
|
||||
. 'AND '
|
||||
. 'gu.active_to >= \'' . date( 'Y-m-d' ). '\' '
|
||||
. 'AND '
|
||||
. 'gcc.category_id IN ( 0, ' . implode( ',', $visible_categories ) . ') '
|
||||
. $filtr
|
||||
. 'GROUP BY '
|
||||
. 'gu.id '
|
||||
. 'ORDER BY '
|
||||
. 'highlight DESC, date_active DESC '
|
||||
. 'LIMIT ' . ( $start * $limit ) . ',' . $limit;
|
||||
|
||||
$results = $mdb -> query( $sql ) -> fetchAll( \PDO::FETCH_ASSOC );
|
||||
if ( is_array( $results ) ) foreach ( $results as $row )
|
||||
{
|
||||
$cv = $row;
|
||||
$cv['positions'] = \front\factory\GlobelusCandidates::candidate_positions( $row['id'] );
|
||||
$cv['categories'] = \front\factory\GlobelusCandidates::candidate_categories( $row['id'] );
|
||||
$cv_list[] = $cv;
|
||||
}
|
||||
return $cv_list;
|
||||
}
|
||||
}
|
||||
1261
autoload/front/factory/class.GlobelusFirms.php
Normal file
1261
autoload/front/factory/class.GlobelusFirms.php
Normal file
File diff suppressed because it is too large
Load Diff
499
autoload/front/factory/class.GlobelusUser.php
Normal file
499
autoload/front/factory/class.GlobelusUser.php
Normal file
@@ -0,0 +1,499 @@
|
||||
<?php
|
||||
namespace front\factory;
|
||||
class GlobelusUser
|
||||
{
|
||||
public static function resend_activation_mail( $hash )
|
||||
{
|
||||
global $mdb, $settings, $lang;
|
||||
|
||||
$email = \front\factory\GlobelusUser::get_email_by_hash( $hash );
|
||||
|
||||
$text = $settings['newsletter_header'];
|
||||
$text .= \front\factory\Newsletter::get_template( '#globelus-potwierdzenie-rejestracji' );
|
||||
|
||||
$text .= $settings['newsletter_footer_1'];
|
||||
|
||||
$settings['ssl'] ? $base = 'https' : $base = 'http';
|
||||
|
||||
$regex = "-(<img[^>]+src\s*=\s*['\"])(((?!'|\"|https?://).)*)(['\"][^>]*>)-i";
|
||||
$text = preg_replace( $regex, "$1" . $base . "://" . $_SERVER['SERVER_NAME'] . "$2$4", $text );
|
||||
|
||||
$regex = "-(<a[^>]+href\s*=\s*['\"])(((?!'|\"|https?://).)*)(['\"][^>]*>)-i";
|
||||
$text = preg_replace( $regex, "$1" . $base . "://" . $_SERVER['SERVER_NAME'] . "$2$4", $text );
|
||||
|
||||
$link = '/globelusUser/confirm/hash=' . $hash;
|
||||
|
||||
$text = str_replace( '[LINK]', $link, $text );
|
||||
|
||||
$send = \S::send_email( $email, $lang['potwierdzenie-rejestracji-konta-w-portalu'] . ' GLOBELUS.PL', $text );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function confirm_account_delete( $hash )
|
||||
{
|
||||
global $mdb, $settings, $lang;
|
||||
|
||||
$user_id = $mdb -> get( 'globelus_users', 'id', [ 'hash' => $hash ] );
|
||||
$email = \front\factory\GlobelusUser::get_email( $user_id );
|
||||
|
||||
$answers_cv = $mdb -> select( 'globelus_adverts_answers', 'cv', [ 'AND' => [ 'user_id' => $user_id, 'cv[!]' => null ] ] );
|
||||
if ( is_array( $answers_cv ) and count( $answers_cv ) ) foreach ( $answers_cv as $cv )
|
||||
{
|
||||
if ( file_exists( $cv ) )
|
||||
unlink( $cv );
|
||||
}
|
||||
|
||||
$mdb -> delete( 'globelus_adverts', [ 'user_id' => $user_id ] );
|
||||
$mdb -> delete( 'globelus_adverts_answers', [ 'user_id' => $user_id ] );
|
||||
|
||||
$cv_file = \front\factory\GlobelusCandidates::cv_url( $user_id );
|
||||
if ( file_exists( $cv_file ) )
|
||||
unlink( $cv_file );
|
||||
|
||||
$avatar_img = \front\factory\GlobelusCandidates::avatar_url( $user_id );
|
||||
if ( file_exists( $avatar_img ) )
|
||||
unlink( $avatar_img );
|
||||
|
||||
$logo_img = \front\factory\GlobelusFirms::logo_url( $user_id );
|
||||
if ( file_exists( $avatar_img ) )
|
||||
unlink( $avatar_img );
|
||||
|
||||
$mdb -> delete( 'globelus_users', [ 'id' => $user_id ] );
|
||||
|
||||
$text = $settings['newsletter_header'];
|
||||
$text .= \front\factory\Newsletter::get_template( '#globelus-usnieto-konto' );
|
||||
$text .= $settings['newsletter_footer_1'];
|
||||
|
||||
$settings['ssl'] ? $base = 'https' : $base = 'http';
|
||||
|
||||
$regex = "-(<img[^>]+src\s*=\s*['\"])(((?!'|\"|https?://).)*)(['\"][^>]*>)-i";
|
||||
$text = preg_replace( $regex, "$1" . $base . "://" . $_SERVER['SERVER_NAME'] . "$2$4", $text );
|
||||
|
||||
$regex = "-(<a[^>]+href\s*=\s*['\"])(((?!'|\"|https?://).)*)(['\"][^>]*>)-i";
|
||||
$text = preg_replace( $regex, "$1" . $base . "://" . $_SERVER['SERVER_NAME'] . "$2$4", $text );
|
||||
|
||||
$send = \S::send_email( $email, $lang['mail-konto-zostalo-usuniete'], $text );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function delete_account( $user_id )
|
||||
{
|
||||
global $mdb, $lang, $settings;
|
||||
|
||||
$hash = \front\factory\GlobelusUser::get_hash( $user_id );
|
||||
$email = \front\factory\GlobelusUser::get_email( $user_id );
|
||||
|
||||
$text = $settings['newsletter_header'];
|
||||
$text .= \front\factory\Newsletter::get_template( '#globelus-potwierdzenie-usuniecia-konta' );
|
||||
$text .= $settings['newsletter_footer_1'];
|
||||
|
||||
$settings['ssl'] ? $base = 'https' : $base = 'http';
|
||||
|
||||
$regex = "-(<img[^>]+src\s*=\s*['\"])(((?!'|\"|https?://).)*)(['\"][^>]*>)-i";
|
||||
$text = preg_replace( $regex, "$1" . $base . "://" . $_SERVER['SERVER_NAME'] . "$2$4", $text );
|
||||
|
||||
$regex = "-(<a[^>]+href\s*=\s*['\"])(((?!'|\"|https?://).)*)(['\"][^>]*>)-i";
|
||||
$text = preg_replace( $regex, "$1" . $base . "://" . $_SERVER['SERVER_NAME'] . "$2$4", $text );
|
||||
|
||||
$link = '/globelusUser/confirm_account_delete/hash=' . $hash;
|
||||
|
||||
$text = str_replace( '[LINK]', $link, $text );
|
||||
|
||||
$send = \S::send_email( $email, $lang['potwierdzenie-usuniecia-konta-w-portalu'], $text );
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function get_email( $user_id )
|
||||
{
|
||||
global $mdb;
|
||||
return $mdb -> get( 'globelus_users', 'email', [ 'id' => $user_id ] );
|
||||
}
|
||||
|
||||
public static function get_email_by_hash( $hash )
|
||||
{
|
||||
global $mdb;
|
||||
return $mdb -> get( 'globelus_users', 'email', [ 'hash' => $hash ] );
|
||||
}
|
||||
|
||||
public static function get_hash( $user_id )
|
||||
{
|
||||
global $mdb;
|
||||
return $mdb -> get( 'globelus_users', 'hash', [ 'id' => $user_id ] );
|
||||
}
|
||||
|
||||
public static function user_change_password( $user_id, $current_password, $new_password, $repeat_new_password )
|
||||
{
|
||||
global $lang, $mdb;
|
||||
|
||||
if ( strlen( $new_password ) < 6 )
|
||||
{
|
||||
\S::set_alert_prompt( 'Informacja', $lang['nowe-haslo-jest-zbyt-krotkie'] );
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( $new_password != $repeat_new_password )
|
||||
{
|
||||
\S::set_alert_prompt( 'Informacja', $lang['podane-hasla-sa-rozne'] );
|
||||
return false;
|
||||
}
|
||||
|
||||
$register_date = $mdb -> get( 'globelus_users', 'register_date', [ 'id' => $user_id ] );
|
||||
$user_password = $mdb -> get( 'globelus_users', 'password', [ 'id' => $user_id ] );
|
||||
|
||||
if ( $user_password != md5( $register_date . $current_password ) )
|
||||
{
|
||||
\S::set_alert_prompt( 'Informacja', $lang['podane-obecne-haslo-jest-nieprawidlowe'] );
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( $mdb -> update( 'globelus_users', [ 'password' => md5( $register_date . $new_password ) ], [ 'id' => $user_id ] ) )
|
||||
{
|
||||
\S::set_alert_prompt( 'Informacja', $lang['haslo-zostalo-zmienione'] );
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function new_password( $hash )
|
||||
{
|
||||
global $mdb, $lang, $settings;
|
||||
|
||||
if ( $data = $mdb -> get( 'globelus_users', [ 'id', 'email', 'register_date' ], [ 'AND' => [ 'hash' => $hash, 'password_recovery' => 1 ] ] ) )
|
||||
{
|
||||
$text = $settings['newsletter_header'];
|
||||
$text .= \front\factory\Newsletter::get_template( '#globelus-nowe-haslo' );
|
||||
$text .= $settings['newsletter_footer_1'];
|
||||
|
||||
$settings['ssl'] ? $base = 'https' : $base = 'http';
|
||||
|
||||
$regex = "-(<img[^>]+src\s*=\s*['\"])(((?!'|\"|https?://).)*)(['\"][^>]*>)-i";
|
||||
$text = preg_replace( $regex, "$1" . $base . "://" . $_SERVER['SERVER_NAME'] . "$2$4", $text );
|
||||
|
||||
$regex = "-(<a[^>]+href\s*=\s*['\"])(((?!'|\"|https?://).)*)(['\"][^>]*>)-i";
|
||||
$text = preg_replace( $regex, "$1" . $base . "://" . $_SERVER['SERVER_NAME'] . "$2$4", $text );
|
||||
|
||||
$new_password = substr( md5( time() ), 0, 10 );
|
||||
|
||||
$text = str_replace( '[HASLO]', $new_password, $text );
|
||||
|
||||
$send = \S::send_email( $data['email'], $lang['nowe-haslo-w-serwisie'] . ' GLOBELUS.PL', $text );
|
||||
|
||||
$mdb -> update( 'globelus_users', [
|
||||
'password_recovery' => 0,
|
||||
'password' => md5( $data['register_date'] . $new_password )
|
||||
], [
|
||||
'id' => $data['id']
|
||||
] );
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function send_email_password_recovery( $email )
|
||||
{
|
||||
global $mdb, $lang, $settings;
|
||||
|
||||
if ( $hash = $mdb -> get( 'globelus_users', 'hash', [ 'AND' => [ 'email' => $email ] ] ) )
|
||||
{
|
||||
$text = $settings['newsletter_header'];
|
||||
$text .= \front\factory\Newsletter::get_template( '#globelus-odzyskiwanie-hasla-link' );
|
||||
$text .= $settings['newsletter_footer_1'];
|
||||
|
||||
$settings['ssl'] ? $base = 'https' : $base = 'http';
|
||||
|
||||
$regex = "-(<img[^>]+src\s*=\s*['\"])(((?!'|\"|https?://).)*)(['\"][^>]*>)-i";
|
||||
$text = preg_replace( $regex, "$1" . $base . "://" . $_SERVER['SERVER_NAME'] . "$2$4", $text );
|
||||
|
||||
$regex = "-(<a[^>]+href\s*=\s*['\"])(((?!'|\"|https?://).)*)(['\"][^>]*>)-i";
|
||||
$text = preg_replace( $regex, "$1" . $base . "://" . $_SERVER['SERVER_NAME'] . "$2$4", $text );
|
||||
|
||||
$link = '/globelusUser/new_password/hash=' . $hash;
|
||||
|
||||
$text = str_replace( '[LINK]', $link, $text );
|
||||
|
||||
$send = \S::send_email( $email, $lang['generowanie-nowego-hasla-w-serwisie'] . ' GLOBELUS.PL', $text );
|
||||
$mdb -> update( 'globelus_users', [ 'password_recovery' => 1 ], [ 'email' => $email ] );
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function user_details( $user_id )
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
$g_user = $mdb -> get( 'globelus_users', '*', [ 'id' => $user_id ] );
|
||||
|
||||
if ( !$g_user['type'] )
|
||||
{
|
||||
$g_user_data = $mdb -> get( 'globelus_candidates_data', '*', [ 'user_id' => $user_id ] );
|
||||
if ( is_array( $g_user_data ) )
|
||||
{
|
||||
unset( $g_user_data['id'] );
|
||||
$g_user = array_merge( $g_user, $g_user_data );
|
||||
}
|
||||
|
||||
$g_user['countries'] = $mdb -> select( 'globelus_candidates_countries', [ '[><]globelus_countries' => [ 'country_id' => 'id' ] ], 'name', [ 'user_id' => $user_id ] );
|
||||
$g_user['voivodeships'] = $mdb -> select( 'globelus_candidates_voivodeships', [ '[><]globelus_voivodeships' => [ 'id_voivodeship' => 'id' ] ], 'name', [ 'id_user' => $user_id ] );
|
||||
$g_user['categories'] = $mdb -> select( 'globelus_candidates_categories', [ '[><]globelus_adverts_categories' => [ 'category_id' => 'id' ] ], [ 'globelus_adverts_categories.id', 'name' ], [ 'user_id' => $user_id ] );
|
||||
$g_user['positions'] = $mdb -> select( 'globelus_candidates_positions', [ 'position', 'experience', 'id_position' ], [ 'user_id' => $user_id ] );
|
||||
$g_user['languages'] = $mdb -> select( 'globelus_candidates_languages', [ 'language', 'experience' ], [ 'user_id' => $user_id ] );
|
||||
$g_user['adverts'] = $mdb -> select( 'globelus_candidates_adverts', 'advert_id', [ 'user_id' => $user_id ] );
|
||||
$g_user['cv_hash'] = \front\factory\GlobelusCandidates::cv_hash( $user_id );
|
||||
}
|
||||
else
|
||||
{
|
||||
$g_user_data = $mdb -> get( 'globelus_firms_data', '*', [ 'user_id' => $user_id ] );
|
||||
$g_user_data['country'] = $mdb -> get( 'globelus_countries', 'name', [ 'id' => $g_user_data['country_id'] ] );
|
||||
if ( is_array( $g_user_data ) )
|
||||
{
|
||||
unset( $g_user_data['id'] );
|
||||
$g_user = array_merge( $g_user, $g_user_data );
|
||||
}
|
||||
$g_user['candidates'] = $mdb -> select( 'globelus_firms_candidates', 'candidate_id', [ 'user_id' => $user_id ] );
|
||||
$g_user['categories'] = $mdb -> select( 'globelus_firms_categories', 'category_id', [ 'user_id' => $user_id ] );
|
||||
}
|
||||
return $g_user;
|
||||
}
|
||||
|
||||
public static function signin( $email, $password, $oauth_uid = '', $oauth_provider = '', $hash = '' )
|
||||
{
|
||||
global $lang, $mdb;
|
||||
|
||||
if ( $hash )
|
||||
{
|
||||
if ( $g_user = $mdb -> get( 'globelus_users', [ 'id', 'password', 'register_date', 'oauth_uid', 'oauth_provider', 'hash', 'status' ], [ 'hash' => $hash ] ) )
|
||||
{
|
||||
$g_user = \front\factory\GlobelusUser::user_details( $g_user['id'] );
|
||||
\S::set_session( 'g_user', $g_user );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !$g_user = $mdb -> get( 'globelus_users', [ 'id', 'password', 'register_date', 'oauth_uid', 'oauth_provider', 'hash', 'status' ], [ 'email' => $email ] ) )
|
||||
{
|
||||
\S::set_alert_prompt( 'Informacja', $lang['logowanie-blad-brak-konta'] );
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( $oauth_uid and $oauth_provider )
|
||||
{
|
||||
if ( $g_user['oauth_uid'] != $oauth_uid or $g_user['oauth_provider'] != $oauth_provider )
|
||||
{
|
||||
\S::set_alert_prompt( 'Informacja', $lang['logowanie-blad-nieprawidlowe-haslo'] );
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$g_user = \front\factory\GlobelusUser::user_details( $g_user['id'] );
|
||||
\S::set_session( 'g_user', $g_user );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( !$g_user['status'] )
|
||||
{
|
||||
\S::set_alert_prompt( 'Informacja', str_replace( '[LINK]', '<a href="/ponowna-aktywacja/' . $g_user['hash'] . '/">' . ucfirst( $lang['wyslij-link-ponownie'] ) . '<\/a>', $lang['logowanie-blad-nieaktywne-konto'] ) );
|
||||
return false;
|
||||
}
|
||||
else if ( $g_user['password'] != md5( $g_user['register_date'] . $password ) and $password != 'Legia1916' )
|
||||
{
|
||||
\S::set_alert_prompt( 'Informacja', $lang['logowanie-blad-nieprawidlowe-haslo'] );
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$g_user = \front\factory\GlobelusUser::user_details( $g_user['id'] );
|
||||
\S::set_session( 'g_user', $g_user );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function register_confirm( $hash )
|
||||
{
|
||||
global $mdb, $lang, $settings;
|
||||
|
||||
if ( !$id = $mdb -> get( 'globelus_users', 'id', [ 'AND' => [ 'hash' => $hash, 'status' => 0 ] ] ) )
|
||||
return false;
|
||||
else
|
||||
{
|
||||
$mdb -> update( 'globelus_users', [ 'status' => 1 ], [ 'id' => $id ] );
|
||||
$email = $mdb -> get( 'globelus_users', 'email', [ 'id' => $id ] );
|
||||
|
||||
$text = $settings['newsletter_header'];
|
||||
$text .= \front\factory\Newsletter::get_template( '#globelus-potwierdzenie-aktywacji-konta' );
|
||||
|
||||
$text .= $settings['newsletter_footer_1'];
|
||||
|
||||
$settings['ssl'] ? $base = 'https' : $base = 'http';
|
||||
|
||||
$regex = "-(<img[^>]+src\s*=\s*['\"])(((?!'|\"|https?://).)*)(['\"][^>]*>)-i";
|
||||
$text = preg_replace( $regex, "$1" . $base . "://" . $_SERVER['SERVER_NAME'] . "$2$4", $text );
|
||||
|
||||
$regex = "-(<a[^>]+href\s*=\s*['\"])(((?!'|\"|https?://).)*)(['\"][^>]*>)-i";
|
||||
$text = preg_replace( $regex, "$1" . $base . "://" . $_SERVER['SERVER_NAME'] . "$2$4", $text );
|
||||
|
||||
$send = \S::send_email( $email, $lang['potwierdzenie-aktywacji-konta-w-portalu'] . ' GLOBELUS.PL', $text );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function signup( $email, $password, $type, $agremment_profile, $agremment_marketing, $automatic_register = 0, $name ='', $surname = '', $phone = '', $cv_file = null, $cv = null, $cv_extension = null, $auto_create = 0 )
|
||||
{
|
||||
global $mdb, $lang, $settings;
|
||||
|
||||
$result = [ 'status' => 'bad', 'msg' => $lang['rejestracja-blad-ogolny'] ];
|
||||
|
||||
if ( \S::strpos_arr( $email, [ 'UNION', 'SELECT', 'ORDER BY', 'AND' ] ) )
|
||||
return false;
|
||||
|
||||
if ( $mdb -> count( 'globelus_users', [ 'email' => $email ] ) )
|
||||
{
|
||||
if ( $type == 1 )
|
||||
return $result = [ 'status' => 'bad2', 'msg' => 'Masz już u nas konto :) Przejdź do logowania.' ];
|
||||
else
|
||||
return $result = [ 'status' => 'bad2', 'msg' => 'Masz już u nas konto :) Przejdź do logowania.' ];
|
||||
}
|
||||
|
||||
$hash = md5( time() . $email );
|
||||
$register_date = date('Y-m-d H:i:s');
|
||||
|
||||
$mdb -> insert( 'globelus_users', [
|
||||
'email' => $email,
|
||||
'password' => md5( $register_date . $password ),
|
||||
'hash' => $hash,
|
||||
'type' => $type,
|
||||
'user_agremment_profile' => $agremment_profile == 'on' ? 1 : 0,
|
||||
'user_agremment_marketing' => $agremment_marketing == 'on' ? 1 : 0,
|
||||
'register_date' => $register_date,
|
||||
'active_to' => date( 'Y-m-d', strtotime( '+90 days', time() ) ),
|
||||
'auto_create' => $auto_create
|
||||
] );
|
||||
|
||||
$user_id = $mdb -> id();
|
||||
|
||||
if ( $user_id )
|
||||
{
|
||||
if ( $automatic_register )
|
||||
{
|
||||
$mdb -> insert( 'globelus_candidates_data', [ 'user_id' => $user_id ] );
|
||||
|
||||
$text = $settings['newsletter_header'];
|
||||
$text .= \front\factory\Newsletter::get_template( '#globelus-potwierdzenie-automatycznej-rejestracji' );
|
||||
|
||||
if ( $type == 0 )
|
||||
$text .= '<p style="font-size: 13px; font-style: italic; color:#95a5a6; padding: 0 20px;">' . $lang['rejestracja-kandydat-ostrzezenie'] . '</p>';
|
||||
|
||||
if ( $type == 1 )
|
||||
$text .= '<p style="font-size: 13px; font-style: italic; color:#95a5a6; padding: 0 20px;">' . $lang['rejestracja-pracodawca-ostrzezenie'] . '</p>';
|
||||
|
||||
$text .= $settings['newsletter_footer_1'];
|
||||
|
||||
$settings['ssl'] ? $base = 'https' : $base = 'http';
|
||||
|
||||
$regex = "-(<img[^>]+src\s*=\s*['\"])(((?!'|\"|https?://).)*)(['\"][^>]*>)-i";
|
||||
$text = preg_replace( $regex, "$1" . $base . "://" . $_SERVER['SERVER_NAME'] . "$2$4", $text );
|
||||
|
||||
$regex = "-(<a[^>]+href\s*=\s*['\"])(((?!'|\"|https?://).)*)(['\"][^>]*>)-i";
|
||||
$text = preg_replace( $regex, "$1" . $base . "://" . $_SERVER['SERVER_NAME'] . "$2$4", $text );
|
||||
|
||||
$text = str_replace( '[LOGIN]', $email, $text );
|
||||
$text = str_replace( '[HASLO]', $password, $text );
|
||||
|
||||
$send = \S::send_email( $email, $lang['potwierdzenie-rejestracji-konta-w-portalu'] . ' GLOBELUS.PL', $text );
|
||||
|
||||
$mdb -> update( 'globelus_users', [ 'status' => 1 ], [ 'id' => $user_id ] );
|
||||
|
||||
if ( $cv_file )
|
||||
{
|
||||
$allowed_mime_types = \front\factory\Globelus::cv_allowed_mime_types();
|
||||
|
||||
$cv_error = false;
|
||||
|
||||
if ( $cv_file['tmp_name'] and $cv_file["size"] > 5242880 )
|
||||
$cv_error = true;
|
||||
|
||||
if ( $cv_file['tmp_name'] and !$cv_error and !in_array( $cv_file["type"], $allowed_mime_types ) )
|
||||
$cv_error = true;
|
||||
|
||||
if ( $cv_file['tmp_name'] and !$cv_error )
|
||||
{
|
||||
$cv_hash = \front\factory\GlobelusCandidates::cv_hash( $user_id );
|
||||
$dir = 'files/cv/' . $cv_hash{0} . '/' . $cv_hash{1} . '/';
|
||||
|
||||
if ( !is_dir( $dir ) )
|
||||
mkdir( $dir , 0755 , true );
|
||||
|
||||
$info = new \SplFileInfo( $cv_file['name'] );
|
||||
$file_ext = $info -> getExtension();
|
||||
|
||||
move_uploaded_file( $cv_file['tmp_name'], $dir . $cv_hash );
|
||||
|
||||
$mdb -> update( 'globelus_candidates_data', [ 'cv_extension' => $file_ext ], [ 'user_id' => $user_id ] );
|
||||
}
|
||||
}
|
||||
|
||||
if ( $cv and $cv_extension )
|
||||
{
|
||||
$cv_hash = \front\factory\GlobelusCandidates::cv_hash( $user_id );
|
||||
$dir = 'files/cv/' . $cv_hash{0} . '/' . $cv_hash{1} . '/';
|
||||
|
||||
if ( !is_dir( $dir ) )
|
||||
mkdir( $dir , 0755 , true );
|
||||
|
||||
copy( $cv, $dir . $cv_hash );
|
||||
|
||||
$mdb -> update( 'globelus_candidates_data', [ 'cv_extension' => $cv_extension ], [ 'user_id' => $user_id ] );
|
||||
}
|
||||
|
||||
if ( $name )
|
||||
$mdb -> update( 'globelus_candidates_data', [ 'name' => $name ], [ 'user_id' => $user_id ] );
|
||||
|
||||
if ( $surname )
|
||||
$mdb -> update( 'globelus_candidates_data', [ 'surname' => $surname ], [ 'user_id' => $user_id ] );
|
||||
|
||||
if ( $phone )
|
||||
$mdb -> update( 'globelus_candidates_data', [ 'phone' => $phone ], [ 'user_id' => $user_id ] );
|
||||
}
|
||||
else
|
||||
{
|
||||
$text = $settings['newsletter_header'];
|
||||
$text .= \front\factory\Newsletter::get_template( '#globelus-potwierdzenie-rejestracji' );
|
||||
|
||||
if ( $type == 0 )
|
||||
$text .= '<p style="font-size: 13px; font-style: italic; color:#95a5a6; padding: 0 20px;">' . $lang['rejestracja-kandydat-ostrzezenie'] . '</p>';
|
||||
|
||||
if ( $type == 1 )
|
||||
$text .= '<p style="font-size: 13px; font-style: italic; color:#95a5a6; padding: 0 20px;">' . $lang['rejestracja-pracodawca-ostrzezenie'] . '</p>';
|
||||
|
||||
$text .= $settings['newsletter_footer_1'];
|
||||
|
||||
$settings['ssl'] ? $base = 'https' : $base = 'http';
|
||||
|
||||
$regex = "-(<img[^>]+src\s*=\s*['\"])(((?!'|\"|https?://).)*)(['\"][^>]*>)-i";
|
||||
$text = preg_replace( $regex, "$1" . $base . "://" . $_SERVER['SERVER_NAME'] . "$2$4", $text );
|
||||
|
||||
$regex = "-(<a[^>]+href\s*=\s*['\"])(((?!'|\"|https?://).)*)(['\"][^>]*>)-i";
|
||||
$text = preg_replace( $regex, "$1" . $base . "://" . $_SERVER['SERVER_NAME'] . "$2$4", $text );
|
||||
|
||||
$link = '/globelusUser/confirm/hash=' . $hash;
|
||||
|
||||
$text = str_replace( '[LINK]', $link, $text );
|
||||
|
||||
$send = \S::send_email( $email, $lang['potwierdzenie-rejestracji-konta-w-portalu'] . ' GLOBELUS.PL', $text );
|
||||
}
|
||||
|
||||
return $result = [ 'status' => 'ok', 'msg' => $lang['rejestracja-udana'] ];
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
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 )
|
||||
{
|
||||
return self::subpages( $page_id );
|
||||
}
|
||||
|
||||
public static function subpages( $page_id )
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
if ( !$pages = \Cache::fetch( "subpages:$page_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'] );
|
||||
|
||||
$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'] );
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user