<?php function is_once_a_compere() { return @basic_member_info('cp_once',false); } function compere_info($key) { global $Config; $default=@$Config->CompereLimits[$key]; if (!$default || is_valid_compere()) return @basic_member_info($key,false); return $default; } function admin_login($dbconn,$login,$passwd) { $admininfo=db_load_admininfo($dbconn); if ($admininfo['login']==$login && $admininfo['pswdhash']==password_hash($passwd)) { $_SESSION[SESSKEYPFX.'admin']=true; return true; } return false; } function is_admin() { return @$_SESSION[SESSKEYPFX.'admin']; } function member_refresh_login($dbconn) { global $Config; $_SESSION[SESSKEYPFX.'status']['login.timestamp']=$_SESSION['uniwits.status']['login.timestamp']; $mb_id=current_mb_id(); if (!$mb_id) { header("Location: qx-cmd-logout.html"); } else { $memberbasic=db_member_basic_by_id($dbconn,$mb_id); if ($memberbasic) { foreach ($memberbasic as $k=>$v) $_SESSION['uniwits.memberbasic'][$k]=$v; update_unread_message_count($dbconn,$mb_id); return true; } } return false; } function get_compere_info_requested($dbconn,$mb_id,$forcereload=false) { global $Config; if ($forcereload || !isset($_SESSION[SESSKEYPFX.'compereinfo.cache'][$mb_id])) { $compereinfo=db_load_compere_info($dbconn,$mb_id); $_SESSION[SESSKEYPFX.'compereinfo.cache'][$mb_id]=rowset2map($compereinfo,'cpi_key','cpi_value'); } return $_SESSION[SESSKEYPFX.'compereinfo.cache'][$mb_id]; } function get_compere_info_default() { global $Config; $compereinfo=$Config->DefaultCompereInfo; $lang=language_requested(); $ccode=get_user_countrycode(); if (is_array($Config->DefaultCompereInfoCategorized[$lang])) { foreach ($Config->DefaultCompereInfoCategorized[$lang] as $k=>$v) $compereinfo[$k]=$v; } if (is_array($Config->DefaultCompereInfoCategorized[$ccode])) { foreach ($Config->DefaultCompereInfoCategorized[$ccode] as $k=>$v) $compereinfo[$k]=$v; } return $compereinfo; } function clear_compere_limits() { unset($_SESSION['uniwits.comperelimit']); } function get_compere_limits($dbconn,$cp_id) { global $Config; if ($_SESSION['uniwits.comperelimit'][$cp_id]) return $_SESSION['uniwits.comperelimit'][$cp_id]; $comperelimit=db_load_compere_current_limit($dbconn,$cp_id); foreach ($Config->Limits as $k=>$v) if (!ctype_digit((string)$comperelimit[$k])) $comperelimit[$k]=$v; $_SESSION['uniwits.comperelimit'][$cp_id]=$comperelimit; return $_SESSION['uniwits.comperelimit'][$cp_id]; } function get_compere_limit($DBConn,$cp_id,$limitname) { global $Config; $limits=get_compere_limits($DBConn,$cp_id); $lv=$limits[$limitname]; if (!$lv) $lv=$Config->Limits[$limitname]; return $lv; } function reserv_logout() { service_logout(SESSKEYPFX); } function get_margin_of_large_vacancy() { return 5; } function format_unilar_amount($amount) { return sprintf("%0.2f",$amount); } function turnoff_mainmenu() { global $dataset; $dataset['MAINMENU']=array(); } function turnoff_mainfooter() { global $dataset; $dataset['MAINFOOTER']=array(); } function get_compere_path($dbconn,$cp_id,$fromurl=null) { if (!$fromurl) $fromurl=$_SERVER['REQUEST_URI']; $path=dirname_ending_with_slash($fromurl); $path=ereg_replace('/cp[0-9]+','',$path); if ($cp_id) return $path."cp".$cp_id."/qx-cmd-searchcourse.html"; else return $path."qx-cmd-searchcourse.html"; } function load_compere_viewcount($cpid) { global $Config; return 0+@file_get_contents($Config->Paths['counter.compere'].'/'.$cpid.'.cnt'); } function save_compere_viewcount($cpid,$count) { global $Config; return 0+@file_put_contents($Config->Paths['counter.compere'].'/'.$cpid.'.cnt',$count); } function load_course_viewcount($cs_id) { global $Config; return 0+@file_get_contents($Config->Paths['counter.course'].'/'.$cs_id.'.cnt'); } function save_course_viewcount($cs_id,$count) { global $Config; return 0+@file_put_contents($Config->Paths['counter.course'].'/'.$cs_id.'.cnt',$count); } function calculate_course_popularity($reservcount,$viewcount) { return floor(log(max(1,$reservcount*10+$viewcount),1.2)); } function set_simple_version($is_use) { SET_LIFELONG_COOKIE('reserv_simple_version',$is_use); } function is_wish_simple_version() { return NOCOOKIE || COOKIE('reserv_simple_version'); } function enable_view_mode_selection(&$dataset) { global $DEPEND_ON_TEMPLATES; if (is_wish_simple_version()) $dataset['SIMPLE-VIEW']=array(0); else $dataset['NORMAL-VIEW']=array(0); } ?>