require_once('class.base.php');
$translate=array(
'en'=>array(
'confirmation_booking'=>'Thank you for your request. We will be in touch shortly.',
'booking_tailormade'=>'Tailor made trip (EN)',
'confirmation_email_subscribe'=>'Thank you for joining to Go Russia mailing list. We look forward to keeping you informed.',
'confirmation_school_presentation'=>'Thank you for your request. We will be in contact shortly.',
'confirmation_school_promomaterials'=>'Thank you for your request. We will be in contact shortly.',
'confirmation_school_quote'=>'Thank you for your request. We will be in contact shortly.',
'confirmation_enquiry'=>'Please fill in the form below and one of our travel consultants will be in touch with you at specified time. ',
'book'=>'book now',
'request'=>'request',
'loading'=>'Loading'
)
);
class Site extends Base {
var $rates=array();
var $menu=array();
function __construct(){
if(isset($_SESSION['message'])){
$this->assign('message',$_SESSION['message']);
unset($_SESSION['message']);
}
$this->template='pages.tpl';
}
function isMobile() {
return preg_match("/(android|avantgo|blackberry|bolt|boost|cricket|docomo|fone|hiptop|mini|mobi|palm|phone|pie|tablet|up\.browser|up\.link|webos|wos)/i", $_SERVER["HTTP_USER_AGENT"]);
}
function main(){
global $vars;
global $db;
if($this->isMobile()){
$this->siteVersion='_mobile';
}
$this->base_init();
$this->get_path();
$this->assign('item', $this->get_text_page($this->sets['section'], 'none'));
$temp=str_replace('-','_',$this->sets['section']);
if(method_exists($this, $temp))
$this->$temp();
else $this->pages();
if(!$this->print_version){
if($this->siteVersion!=''){
// mobile version
$this->menu_list_mobile();
$this->assign('mobile_menu', $this->menu);
// $this->print_v_comment($this->menu);
}
else{
// desktop version
$this->menu_list();
}
}
$this->display($this->template);
exit(0);
}
function popup(){
$this->assign('item', $this->get_text_page($this->sets['item'], 'none'));
$this->template='popup.tpl';
}
function popup_ajax(){
$item=$this->get_text_page($this->sets['item'], 'none');
echo $this->php2js(array(
'title'=>$item['title'],
'text'=>str_replace('href="/', 'href="https://www.stressfreevisas.co.uk/', $item['text'])
));
exit(0);
}
function popup_tips(){
global $db;
$tip=$db->sql2rec('
select
tip_title_'.$_REQUEST['lang'].' as title,
tip_text_'.$_REQUEST['lang'].' as text
from tips
where tip_id='.$_REQUEST['id']);
echo $this->php2js($tip);
exit(0);
}
function get_link($str){
$temp = explode('>',$str);
$temp[0] = str_replace("'", '', $temp[0]);
$temp[0] = explode('=',$temp[0]);
$temp[0][1] = trim($temp[0][1]);
$temp[1] = explode('<',$temp[1]);
$temp[1][0] = trim($temp[1][0]);
return array('link'=>$temp[0][1], 'title'=>$temp[1][0]);
}
function menu_list(){
global $db;
$menu=$db->sql2array('select * from menu_groups where group_public="y"');
unset($this->menu);
$main_menu=array();
$mg=array();
if($menu)
foreach($menu as $m){
$mg[]=$m['group_id'];
$main_menu[$m['group_id']]=array();
}
// select first level
$sql='select page_id, page_group_id,
page_redirect, page_url,
page_dir, a.page_menu as page_title
from pages_'.$this->sets['lang'].' a
left join pages on page_id=page_link
where page_show="y" and page_parent_id=1 and page_group_id in ('.implode(',',$mg).')
order by page_group_id, page_sort_id asc';
$res=$db->sql2array($sql);
if($res && sizeof($res)>0){
$IN='';
foreach ($res as $v){
if($v['page_redirect']=='y')
$link=$v['page_url'];
elseif(strpos($v['page_title'],'get_link($v['page_title']);
$v['page_title'] = $rez['title'];
$link = $rez['link'];
}
else $link='/'.$v['page_dir'].'.html';
// submenu
$subar=false;
$main_menu[$v['page_group_id']][]=array(
'page_id'=>$v['page_id'],
'page_title'=>$v['page_title'],
'page_dir'=>$v['page_dir'],
'url'=>$link,
'sub'=>$subar
);
}
}
$this->assign('menu', $main_menu);
}
function upload_file($file, $path, $name){
$file_path=(strpos($path, $_SERVER['DOCUMENT_ROOT'])===false)
?$_SERVER['DOCUMENT_ROOT'].$path:$path;
if (file_exists($file['tmp_name'])){
if(move_uploaded_file($file['tmp_name'], $file_path.$name)){
chmod($file_path.$name, 0777);
return true;
}
else{
$this->errors[]="Error. File not saved. try again.";
return false;
}
}
else return false;
}
function biometrics(){
global $vars, $db;
if($_SERVER['SERVER_NAME']=='visa')
$domain='http://gorussia/';
else $domain='https://www.onlineholidayplanner.com/';
//header('Location: '.$domain.$_REQUEST['path'].'?visa=1');
//exit(0);
// query string generation
$query=array();
$temp=@explode('&', $_SERVER['QUERY_STRING']);
if($temp)
foreach($temp as $t){
$var=@explode('=',$t);
if($var[0]!='path')
$query[]=$t;
}
$query=@implode('&', $query);
if($query && !empty($query))
$query='?'.$query.'&visa=1';
else $query='?visa=1';
$path='/'.$_REQUEST['path'].$query;
$method='GET';
$data=''; $cookies='';
// POST vars
if($_POST && sizeof($_POST)>0){
$method='POST';
foreach($_POST as $k=>$v){
if(is_array($v)){
$data.=post_var_array($k, $v);
}
else $data.=urlencode($k).'='.urlencode($v).'&';
}
$data = substr($data,0,-1);
}
// Cookies
$cookie=($_COOKIE)?$_COOKIE:$HTTP_COOKIE_VARS;
if($cookie && sizeof($cookie)>0){
foreach ($cookie as $k => $v)
$cookies.=urlencode($k).'='.urlencode($v).'; ';
// Client IP
$cookies.=urlencode('IP').'='.urlencode($_SERVER['REMOTE_ADDR']).'; ';
$cookies = substr($cookies,0,-2);
}
$fp = fsockopen('www.onlineholidayplanner.com', 80, $errno, $errstr, 30);
if (!$fp) {
//echo "$errstr ($errno)
\n";
die('fsockopen connection error: '.$errno.' '.$errstr);
}
fputs($fp, $method." ".$path." HTTP/1.1\r\n");
fputs($fp, "Host: www.onlineholidayplanner.com\r\n");
if (!empty($cookies)){
fputs($fp, "Cookie: ".$cookies."\r\n");
}
if(!empty($data)){
fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
fputs($fp, "Content-length: ".strlen($data)."\r\n");
fputs($fp, "Connection: close\r\n\r\n");
fputs($fp, $data."\r\n\r\n");
}
else{
fputs($fp, "Connection: close\r\n\r\n");
}
$headers = array();
$str = trim(fgets($fp));
while ($str){
$headers[]=$str;
$str = trim(fgets($fp));
}
$body = '';
while (!feof($fp))$body.=fgets($fp);
fclose($fp);
$html=parseHttpResponse($headers, $body);
//$html=file_get_contents($domain.$vars['path']);
//$html=str_replace('"/images','"'.$domain.'/images', $html);
echo fix_urls($html, $domain);
die();
}
function info_print(){
global $vars, $db;
$page=$this->get_var('item');
setDBConnection('tms');
$p=$db->sql2rec('select * from pages_en where page_dir="'.$this->sets['item'].'"');
$page['page_title']=$p['page_title'];
$page['title']=$p['page_topic'];
$page['text']=$p['page_text'];
setDBConnection('visa');
$this->assign('item', $page);
$this->template='popup.tpl';
}
function info(){
global $vars, $db;
$page=$this->get_var('item');
setDBConnection('gorussia');
$p=$db->sql2rec('select * from pages_en where page_dir="'.$this->sets['item'].'"');
$page['page_title']=$p['page_title'];
$page['title']=$p['page_topic'];
$page['text']=$p['page_text'];
setDBConnection('visa');
/*
if($_SERVER['SERVER_NAME']=='visa')
$domain='http://gorussia';
else $domain='https://www.onlineholidayplanner.com';
///en/print_version/visa_guidance.html
$url='/en/'.str_replace('info', 'print_version', $vars['path']).'.html';
$html=file_get_contents($domain.$url);
$html=str_replace('"/images','"'.$domain.'/images', $html);
$html=explode('
', $html);
unset($html[sizeof($html)-1]);
$html=implode('
', $html);
//echo '';
$html=explode('', $html);
unset($html[0]);
$html=implode('
', $html);
//echo '';
$html=explode('
', $html);
$page['title']=$html[0];
unset($html[0]);
$page['text']=implode('
', $html);
//print_r($page);
*/
$this->assign('item', $page);
$this->template='pages.tpl';
}
function visa_office_holidays(){
global $db;
setDBConnection('tms');
$res=$db->sql2array('
select tms_service_visa_voucher_holidays.*,
date_format(day_from, "%Y") as year,
date_format(day_from, "%w") as from_day,
date_format(day_from, "%e") as from_date,
date_format(day_from, "%c") as from_month,
date_format(day_till, "%w") as till_day,
date_format(day_till, "%e") as till_date,
date_format(day_till, "%c") as till_month
from tms_service_visa_voucher_holidays
where day_from>now()
order by day_from
');
setDBConnection($this->site);
$txt='';
if($res){
$city=array(
array(
'field'=>'day_london',
'title'=>'London',
'table'=>''
),
array(
'field'=>'day_edinburgh',
'title'=>'Edinburgh',
'table'=>''
),
array(
'field'=>'day_manchester',
'title'=>'Manchester',
'table'=>''
)
);
foreach($res as $v){
$v['from_day']=$this->weekday[$v['from_day']];
$v['till_day']=$this->weekday[$v['till_day']];
$v['from_month']=$this->months[$v['from_month']-1];
$v['till_month']=$this->months[$v['till_month']-1];
if($v['from_month']!=$v['till_month']){
$date=$v['from_date'].' '.$v['from_month'].' - '.$v['till_date'].' '.$v['till_month'];
$day=$v['from_day'].' - '.$v['till_day'];
}
elseif($v['from_date']!=$v['till_date']){
$date=$v['from_date'].' - '.$v['till_date'].' '.$v['from_month'];
$day=$v['from_day'].' - '.$v['till_day'];
}
else {
$date=$v['from_date'].' '.$v['from_month'];
$day=$v['from_day'];
}
$date.=' '.$v['year'];
$txt='
| '.$date.' |
'.$day.' |
'.$v['day_title'].' |
';
if($city)
foreach($city as $k=>$c){
if($v[$c['field']]=='y')
$city[$k]['table'].=$txt;
}
}
$txt='';
if($city)
foreach($city as $k=>$c){
if(!empty($c['table'])){
$txt.='
'.$c['title'].'
| Date |
Day |
Holiday |
'.$c['table'].'
';
}
}
}
return $txt;
}
function pages(){
$page=$this->get_var('item');
if($this->siteVersion!=''){
// mobile version
if($page['dir']=='visa-centre-russia-info'){
$table=$this->visa_office_holidays();
$page['text']=str_replace('PUBLIC HOLIDAYS
', 'PUBLIC HOLIDAYS
'.$table, $page['text']);
$this->assign('item', $page);
}
if(in_array($page['group'], array(1,2,3,4))){
return $this->page_country_mobile($page);
}
}
else{
// desktop version
if($page['dir']=='visa-centre-russia-info'){
$table=$this->visa_office_holidays();
$page['text']=str_replace('PUBLIC HOLIDAYS
', 'PUBLIC HOLIDAYS
'.$table, $page['text']);
$this->assign('item', $page);
}
if($page['parent']!=1 && $page['group']==3){
return $this->page_country($page);
}
}
$this->assign('countries', $this->countries());
$this->template='pages.tpl';
}
function page_parent($id){
global $db;
$sql='select page_id, page_priority, page_facebook,
page_url, page_redirect,
page_group_id, page_parent_id,
page_dir, page_add,
page_title'.$this->siteVersion.',
page_topic'.$this->siteVersion.',
page_text'.$this->siteVersion.',
a.page_menu'.$this->siteVersion.',
page_keywords, page_description
from pages_'.$this->sets['lang'].' a
left join pages'.$this->siteVersion.' on page_id=page_link
where page_id='.$id;
return $this->get_text_page_array($db->sql2rec($sql));
}
function countries(){
global $db;
return $db->sql2array('
select page_id, page_dir, b.page_menu
from pages a
left join pages_en b on page_id=page_link
where
page_group_id=3 and
page_parent_id in (
select page_id from pages
where page_group_id=3 and page_show="y" and page_parent_id=1
) and
page_show="y"
order by b.page_menu
');
}
function page_country_bookmarks($page){
global $db;
// get country page
$temp=$page;
while($temp){
$block=$this->page_parent($temp['parent']);
if($block['parent']==1){
$country=$temp;
$temp=false;
break;
}
else $temp=$block;
}
// all sub pages
$sql='select page_id, page_url, page_redirect,
page_dir, a.page_menu
from pages_'.$this->sets['lang'].' a
left join pages on page_id=page_link
where page_show="y" and page_parent_id='.$country['id'].'
order by page_sort_id';
$bookmarks=$db->sql2array($sql, 'page_id');
$this->assign('bookmarks', $bookmarks);
if(isset($bookmarks[$page['id']])){
$opened=$page;
}
else{
$opened=current($bookmarks);
$opened=$this->get_text_page($opened['page_dir'], 'none');
}
// content country page, meta data of current bookmark
$item=$opened;
$item['title']=$country['title'];
$item['text']=$country['text'];
$item['right']=$country['right'];
$this->assign('item', $item);
$this->assign('bookmark', $opened);
$this->assign('country', $country);
$this->assign('countries', $this->countries());
return $opened;
}
function page_country_bookmarks_mobile($page){
global $db;
// get country page
$temp=$page;
while($temp){
if($temp['parent']==1){
$country=$temp;
$temp=false;
break;
}
else $temp=$this->page_parent($temp['parent']);
}
// all sub pages
$sql='select page_id, page_url, page_redirect,
page_dir, a.page_menu'.$this->siteVersion.' as page_menu
from pages_'.$this->sets['lang'].' a
left join pages'.$this->siteVersion.' on page_id=page_link
where page_show="y" and page_parent_id='.$country['id'].'
order by page_sort_id';
$bookmarks=$db->sql2array($sql, 'page_id');
//print_r($bookmarks);
$this->assign('bookmarks', $bookmarks);
$this->assign('country', $country);
return $page;
}
function page_country($page){
global $db;
$opened=$this->page_country_bookmarks($page);
$visa=$db->sql2rec('
select visa_type, visa_country
from visas
where visa_page='.$opened['id'].'
');
// visa prices
if($visa){
setDBConnection('tms');
$is_available=$db->sql2value('select tbc_visapayable from tms_destination_countries where tbc_id='.$visa['visa_country']);
$arr=$this->visa_packages(2, $visa['visa_country'], $visa['visa_type']);
setDBConnection($this->site);
// Schema product visas
if($visa['visa_country']==5){
$this->assign('schema_product', 'Russian '.$opened['menu']);
}
else{
$this->assign('schema_product', $opened['menu'].' Visa');
}
}
$this->assign('is_available', @$is_available);
$this->assign('visas', @$arr);
$this->assign('visa_details',$visa['visa_country'].'-'.$visa['visa_type']);
$this->template='pages_country.tpl';
}
function page_country_mobile($page){
global $db;
$opened=$this->page_country_bookmarks_mobile($page);
if ($page['parent']!=1){
$visa=$db->sql2rec('
select visa_type, visa_country
from visas
where visa_page='.$page['id'].'
');
// visa prices
if($visa){
setDBConnection('tms');
$is_available=$db->sql2value('select tbc_visapayable from tms_destination_countries where tbc_id='.$visa['visa_country']);
$arr=$this->visa_packages(2, $visa['visa_country'], $visa['visa_type']);
setDBConnection($this->site);
// Schema product visas
if($visa['visa_country']==5){
$this->assign('schema_product', 'Russian '.$opened['menu']);
}
else{
$this->assign('schema_product', $opened['menu'].' Visa');
}
}
$this->assign('is_available', @$is_available);
$this->assign('visas', @$arr);
$this->assign('visa_details',$visa['visa_country'].'-'.$visa['visa_type']);
}
$this->template='pages_country.tpl';
}
function russian_tourist_voucher(){
global $db;
// boormarks
if($this->siteVersion!=''){
$opened=$this->page_country_bookmarks_mobile($this->get_var('item'));
}
else{
$opened=$this->page_country_bookmarks($this->get_var('item'));
}
setDBConnection('tms');
$sql='
select vc_id, vc_nik, vc_'.$this->sets['lang'].' as vc_title
from tms_service_visa_citizenship
where vc_id in (
select distinct vv_citizen
from tms_service_visa_voucher_'.$this->sets['lang'].'
)
order by vc_id
';
$citizen=$db->sql2array($sql);
$entry=array();
if($citizen){
foreach ($citizen as $k=>$v){
$sql='
select ve_id, ve_'.$this->sets['lang'].' as ve_title
from tms_service_visa_entry
where ve_id in (
select distinct vv_entry
from tms_service_visa_voucher_'.$this->sets['lang'].'
where vv_citizen='.$v['vc_id'].'
)
order by ve_id
';
$ee=$db->sql2array($sql, 've_id');
$entry[$v['vc_id']]=$ee;
// concat(vvp_from, " - ", vvp_till) as period,
$sql='select
vvp_'.$this->sets['lang'].' as processing,
vvp_till as period,
vv_entry, vv_id, vv_price
from tms_service_visa_voucher_'.$this->sets['lang'].'
left join tms_service_visa_voucher_processing pr on vv_processing=pr.vvp_id
left join tms_service_visa_voucher_period pe on vv_period=pe.vvp_id
where vv_citizen='.$v['vc_id'].' and vv_type=1
order by vv_price, vv_processing, vv_entry, vvp_from';
$res=$db->sql2array($sql);
$data=array();
$columns=array();
$lowest=99999999999;
if($res)
foreach($res as $r){
if($r['vv_price']<$lowest)$lowest=$r['vv_price'];
if(!isset($data[$r['processing']])){
$data[$r['processing']]=array();
}
$index=$ee[$r['vv_entry']]['ve_title'].' eee
'.$r['period'].' ddd';
if(!in_array($index, $columns)) $columns[]=$index;
$data[$r['processing']][$index]=$r['vv_price'];
}
$citizen[$k]['prices']=$data;
$citizen[$k]['lowest']=$lowest;
$citizen[$k]['columns']=$columns;
}
// Schema product visas
$this->assign('schema_product', 'Russian '.$opened['menu']);
}
setDBConnection($this->site);
$this->assign('invitation', $citizen);
$this->assign('entry', $entry);
$this->template='pages_invitation.tpl';
}
function index(){
global $db;
$this->assign('top', $this->get_text_page('home_top', 'none'));
$links=$db->sql2array('
select visa_country, visa_type, page_dir
from pages
left join pages_en a on page_id=page_link
left join visas on page_id=visa_page
where page_show="y"
and visa_country is not null
and visa_type<>0
');
$groups=$db->sql2array('
select page_id, page_dir, b.page_menu
from pages a
left join pages_en b on page_id=page_link
where
page_group_id=3 and
page_parent_id=1 and
page_show="y"
order by page_sort_id
', 'page_dir');
$countries=array();
if($groups)
foreach($groups as $k=>$v){
$groups[$k]['country']=$db->sql2array('
select page_id, page_dir, b.page_menu, visa_country
from pages a
left join pages_en b on page_id=page_link
left join visas on page_id=visa_page
where
page_group_id=3 and
page_parent_id='.$v['page_id'].' and
page_show="y"
order by b.page_menu
');
if(!is_array($groups[$k]['country']))
$groups[$k]['country']=array();
$countries=array_merge($countries, $groups[$k]['country']);
}
usort($countries, array_key('page_menu'));
$this->assign('countries', $countries);
$this->assign('groups', $groups);
$this->assign('links', $links);
$this->template='index.tpl';
}
function get_letter($code=''){
global $db;
$temp=$this->smarty_vars;
$t=$db->sql2rec('
select *
from letters_blank
where
lb_lang="'.$this->sets['lang'].'" and
lb_code="'.$code.'"
');
$mes=$this->fetch($t['lb_template']);
$this->smarty_vars=$temp;
return array(
'subject'=>$t['lb_subject'],
'message'=>$mes
);
}
function confirm_letter($to='', $code=''){
global $vars;
$letters=array(
'account_request'=>array(
'subject'=>'Thank You for Your Request!!!',
'template'=>'letters/account_request.tpl'
)
);
$content=$letters[$code];
$content['message']=$this->fetch($content['template']);
$this->send_mail($to, $content['subject'], $content['message']);
}
function account_request_form(){
global $vars, $translate;
if(isset($vars['action']) && $vars['action']=='send'){
if(!isset($this->sets['email']))
$this->get_sets();
$this->send_request('Account request');
$this->confirm_letter($vars['Email'], 'account_request');
$_SESSION['message']=$translate[$this->sets['lang']]['confirmation_booking'];
return $this->header('/thankyou_account.html');
}
$this->sets['sitekey']=SITE_KEY;
$this->template='account_request_form.tpl';
}
function getCaptcha($SecretKey) {
$Response = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".SECRET_KEY."&response={$SecretKey}");
$Return = json_decode($Response);
return $Return;
}
function send_request($subject){
global $vars;
global $db;
if(isset($vars['g-recaptcha-response'])){
$recaptcha=$vars['g-recaptcha-response'];
}
elseif(isset($vars['recaptcha'])){
$recaptcha=$vars['recaptcha'];
}
$Return = $this->getCaptcha($recaptcha);
/*
print_r($vars);
print_r($Return);
die();
*/
if($Return->success == true && $Return->score > 0.5){
$system=array('path','action','recaptcha','g-recaptcha-response');
$text='';
if(isset($vars))
foreach ($vars as $k=>$v)
if(!in_array($k, $system)){
$k=str_replace('_',' ',$k);
$text.="| ".str_replace('"','\"',$k)." | ";
$text.=(empty($v))?' ':str_replace('"','\"',$v);
$text.=" |
";
}
$ip=(isset($_COOKIE['IP']))?$_COOKIE['IP']:$_SERVER['REMOTE_ADDR'];
$text.='
| IP |
'.$ip.' - view location |
';
$text.='
';
//$this->sets['email']='sergey.lubchenko@gmail.com';
$this->send_mail($this->sets['email'], $subject, $text);
$sql=sprintf("insert into letters set l_date=now(), l_type='%s', l_subject='%s', l_message='%s'",
$subject,
$db->quote_field($subject),
$db->quote($text));
$db->query($sql);
}
}
function call_back(){
global $translate;
global $vars;
$this->sets['email']='visa@justgorussia.co.uk';
$this->send_request('Call back');
$text=$translate[$this->sets['lang']]['confirmation_enquiry'];
echo $this->php2js(array(
'error'=>0,
'message'=>$text
));
exit(0);
}
function contact_us(){
$this->sets['sitekey']=SITE_KEY;
$this->assign('countries', $this->countries());
date_default_timezone_set('Europe/London');
$this->assign('h', date('H'));
$this->template='pages.tpl';
}
function correct_string($data){
$data=str_replace('”','"',$data);
$data=iconv('cp1251', 'utf-8', $data);
return $data;
}
function subscribe_newletter(){
global $db, $translate;
global $vars;
$subject='Join to newsletter';
$message="
Join to newsletter
Email: {$vars['email']}
Language: {$this->sets['lang']}
";
$this->send_mail($this->sets['email'], $subject, $message);
$sql=sprintf("insert into letters set l_date='%s', l_subject='%s', l_message='%s'",
date('Y-m-d'),
$db->quote_field($subject),
$db->quote($message));
$db->query($sql);
die("document.forms['search_form'].newsletter.value='';alert('{$translate[$this->sets['lang']]['confirmation_email_subscribe']}'); ");
}
/*
function pages_counter($current_page, $total, $per_page){
$pages_display=10;
$pages=floor($total/$per_page);
$pages+=($total%$per_page==0)?0:1;
$page_list=array();
$start=1; $finish=$pages;
// if($pages<=$pages_display){$start=1; $finish=$pages;}
// else{
// if($current_page<=floor($pages_display/2)){$start=1; $finish=$pages_display;}
// elseif($pages-$current_page<=floor($pages_display/2)){$start=$pages-$pages_display+1; $finish=$pages;}
// else {$start=$current_page-floor($pages_display/2); $finish=$start+$pages_display-1;}
// }
for($i=$start;$i<=$finish;$i++) $page_list[]=$i;
if($current_page>1)$previous=$current_page-1; else $previous=-1;
if($current_page<$pages)$next=$current_page+1; else $next=-1;
if(sizeof($page_list)<2)$page_list=false;
$this->assign('cur_page', $current_page);
$this->assign('pages', $page_list);
$this->assign('next', $next);
$this->assign('previous', $previous);
}
*/
function customer_frame(){
global $vars;
$this->page_path();
$customer_path=str_replace('customer/', '', $vars['path']);
$this->assign('customer_path', $customer_path);
$this->template='customer.tpl';
}
function customer(){
global $vars;
$vars['path']=$vars['path'].'.html';
$customer_path=str_replace('customer.html', 'customer/login.html', $vars['path']);
if(empty($customer_path)) $customer_path='/'.$this->sets['lang'].'/customer/';
$customer_path='https://'.str_replace('www.', 'customer.', $_SERVER['HTTP_HOST']).'/en/'.$customer_path;
require_once 'class.cabinet.php';
$cabinet=new CustomerCabinet();
//$this->print_v_comment($customer_path);
/**/
if(isset($vars['do']) && $vars['do']=='html'){
$html=$cabinet->process_block($customer_path);
die($html);
}
else{
$html=$cabinet->process_page($customer_path);
}
$this->assign('customer_html', $html);
$this->template='customer_noframe.tpl';
}
function customer_old(){
global $vars;
$this->siteVersion='';
require_once('class.customer.php');
$user=new CustomerAccount();
$user->smarty_vars=&$this->smarty_vars;
$user->template=&$this->template;
$user->errors=&$this->errors;
$user->sets=&$this->sets;
$method=@$this->sets['item'];
if(method_exists($user, $method))
$user->$method();
else $user->undefined();
}
function renew_password(){
global $vars, $db;
$translate=array(
'en'=>array(
'data_saved'=>'Data saved',
'data_not_saved'=>'Error. Try again',
'customer_not_found'=>'Customer not found!'
),
'es'=>array(
'data_saved'=>'Datos guardados.',
'data_not_saved'=>'Error. Inténtalo de nuevo',
'customer_not_found'=>'Cliente no encontrado.'
),
'us'=>array(
'data_saved'=>'Data saved',
'data_not_saved'=>'Error. Try again',
'customer_not_found'=>'Customer not found!'
),
'fr'=>array(
'data_saved'=>'Sauver',
'data_not_saved'=>'Erreur ! Réessayez',
'customer_not_found'=>'Client pas trouvé !'
),
'de'=>array(
'data_saved'=>'Daten gespeichert',
'data_not_saved'=>'Fehler! Versuchen Sie es erneut',
'customer_not_found'=>'Kunde nicht gefunden!'
),
);
setDBConnection('tms');
$vars['new_password']=trim($vars['new_password']);
if(isset($vars['cus_id']) && is_numeric($vars['cus_id']) && !empty($vars['new_password'])){
// set password
$sql=sprintf("
update tms_client set
cus_pass='%s',
cus_hash=md5('%s')
where cus_id=%d
",
$vars['new_password'],
$vars['new_password'],
$vars['cus_id']);
$res=$db->query($sql);
if(!$res){
$this->errors[]=$translate[$this->sets['lang']]['data_not_saved'].$sql;
}
else{
$this->errors[]=$translate[$this->sets['lang']]['data_saved'];
}
return $this->header('/customer/login.html');
die();
}
$client=$db->sql2rec('
select cus_id, cus_email, cus_fname, cus_lname
from tms_client
where md5(concat("GR", cus_email))="'.trim($this->sets['item']).'"
');
if(!$client){
$this->errors[]=$translate[$this->sets['lang']]['customer_not_found'];
return $this->header('/customer/login.html');
}
$this->assign('client', $client);
$this->template='customer/renew_password.tpl';
setDBConnection($this->site);
}
}
?>