| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243 |
- <?php
- class admin_utils {
- // Bcrypt hash for an admin password.
- static function hashPassword($plain) {
- return password_hash($plain, PASSWORD_DEFAULT);
- }
- // Verify a plain password against a stored value.
- // Returns true on match. Handles legacy plaintext passwords:
- // if the stored value is not a recognised hash, it falls back to a
- // direct comparison so existing accounts keep working until rehashed.
- static function verifyPassword($plain, $stored) {
- $info = password_get_info($stored);
- if ($info['algo'] !== null && $info['algo'] !== 0) {
- return password_verify($plain, $stored);
- }
- // Legacy plaintext fallback.
- return hash_equals((string)$stored, (string)$plain);
- }
- // Whether a stored password value is still legacy plaintext and should
- // be upgraded to a proper hash after a successful login.
- static function passwordNeedsRehash($stored) {
- $info = password_get_info($stored);
- return ($info['algo'] === null || $info['algo'] === 0);
- }
- static function dbconnect() {
- global $config;
- global $conn;
- $conn = mysqli_connect($config['db_host'],$config['db_username'],$config['db_password'],$config['db_name']);
- mysqli_query($conn,"SET NAMES utf8");
- mysqli_set_charset($conn, 'utf8mb4');
- return true;
- }
- static function getText($id, $field) {
- self::dbconnect();
- global $conn;
- $res = mysqli_query($conn,"SELECT * FROM azonics_text_pages WHERE page_id='".$id."';");
- if (mysqli_num_rows($res)>0) {
- $row = mysqli_fetch_array($res);
- $text = $row[$field];
- $text = str_replace("<div>","",$text);
- $text = str_replace("</div>","",$text);
- $text = str_replace("<p>","",$text);
- $text = str_replace("</p>","",$text);
- $text = str_replace("<span>","",$text);
- $text = str_replace("</span>","",$text);
- return $text;
- }
- else {
- return 'No data available';
- }
- }
-
- static function getAdminName() {
- return $_SESSION['admin_user']->admin_real_name;
- }
-
-
- static function getAdminAccessLevels($selected='') {
- self::dbconnect();
- global $conn;
-
- $result = mysqli_query($conn,"select * from azonics_roles where role_status='1' order by role_name asc;");
-
- $temp = '<option value="">'.lang::_('Please select admin user access level...').'</option>';
-
- if (mysqli_num_rows($result)>0) {
- while ($row = mysqli_fetch_array($result)) {
- if ($_SESSION['access_level'] == 11) {
- if ($selected==$row['role_id']) {
- $temp.= '<option value="'.$row['role_id'].'" selected>'.$row['role_name'].'</option>';
- }
- else {
- $temp.= '<option value="'.$row['role_id'].'">'.$row['role_name'].'</option>';
- }
- }
- else if ($_SESSION['access_level'] == 13) {
- if ($row['role_id'] == 14) {
- $temp.= '<option value="'.$row['role_id'].'" selected>'.$row['role_name'].'</option>';
- }
- }
- }
- }
- else {
- $temp.= '<option value="">'.lang::_('Actually no active role group...').'</option>';
- }
-
- return $temp;
- }
-
- static function getUserTypes($selected='') {
- self::dbconnect();
- global $conn;
- $result = mysqli_query($conn,"select * from azonics_user_types where user_type_status='1' order by user_type_name asc;");
-
- $temp = '<option value="">'.lang::_('Please select user type...').'</option>';
-
- if (mysqli_num_rows($result)>0) {
- while ($row = mysqli_fetch_array($result)) {
- if ($selected==$row['user_type_id']) {
- $temp.= '<option value="'.$row['user_type_id'].'" selected>'.$row['user_type_name'].'</option>';
- }
- else {
- $temp.= '<option value="'.$row['user_type_id'].'">'.$row['user_type_name'].'</option>';
- }
- }
- }
- else {
- $temp.= '<option value="">'.lang::_('Actually no active user type...').'</option>';
- }
-
- return $temp;
- }
-
-
- static function getUserTypeName($type='') {
- self::dbconnect();
- global $conn;
- if ($type!='') {
- $result = mysqli_query($conn,"select * from azonics_user_types where user_type_id='".$type."';");
- if (mysqli_num_rows($result)>0) {
- $row = mysqli_fetch_array($result);
- return '<span class="'.$row['user_type_color'].'">'.$row['user_type_name'].'</span>';
- }
- else {
- return false;
- }
- }
- else {
- return false;
- }
- }
-
-
- static function getUserState($user_id='') {
- self::dbconnect();
- global $conn;
- if ($user_id!='') {
- $result = mysqli_query($conn,"select * from users where id='".$user_id."';");
- if (mysqli_num_rows($result)>0) {
- $row = mysqli_fetch_array($result);
- if ($row['status']=='1') {
- return ' checked';
- }
- else {
- return '';
- }
- }
- else {
- return '';
- }
- }
- else {
- return '';
- }
- }
- static function getUserName($user_id='') {
- self::dbconnect();
- global $conn;
- if ($user_id!='') {
- $result = mysqli_query($conn,"select * from azonics_users where user_id='".$user_id."';");
- if (mysqli_num_rows($result)>0) {
- $row = mysqli_fetch_array($result);
- return $row['user_first_name']." ".$row['user_last_name'];
- }
- else {
- return '';
- }
- }
- else {
- return '';
- }
- }
-
-
- static function getUserDefaultMailerState($user_id='') {
- self::dbconnect();
- global $conn;
- if ($user_id!='') {
- $result = mysqli_query($conn,"select * from azonics_users where user_id='".$user_id."';");
- if (mysqli_num_rows($result)>0) {
- $row = mysqli_fetch_array($result);
- if ($row['user_default_mailer_status']=='1') {
- return ' checked';
- }
- else {
- return '';
- }
- }
- else {
- return '';
- }
- }
- else {
- return '';
- }
- }
-
-
- static function checkAdminAccessToModule($module='') {
- self::dbconnect();
- global $conn;
- if ($module!='') {
- $result = mysqli_query($conn,"select * from azonics_modules_role where "
- . "modrole_role_id='".$_SESSION['admin_user']->admin_access_level."' and "
- . "modrole_module_id='".$module."' and "
- . "modrole_status='1';");
-
- if (mysqli_num_rows($result)>0) {
- return true;
- }
- else {
- return false;
- }
- }
- else {
- return false;
- }
- }
-
-
- static function getMenu($parent=0) {
- self::dbconnect();
- global $conn;
- $result = mysqli_query($conn,"select * from azonics_modules where module_status='1' and module_display_parent='".$parent."' order by display_order asc;") or die(mysql_error());
-
- $resultObjects = null;
-
- if (mysqli_num_rows($result)>0) {
- while($row = mysqli_fetch_object($result)) {
- if (self::checkAdminAccessToModule($row->module_id)) {
- $resultObjects[] = $row;
- }
- }
- return $resultObjects;
- }
- else {
- return $resultObjects;
- }
- }
-
- static function checkMenuActive($slug='') {
- if (stristr($_SERVER['REQUEST_URI'],$slug)) {
- return ' active';
- }
- else {
- return '';
- }
- }
-
-
- static function checkSubmenuActive($moduleID='') {
- self::dbconnect();
- global $conn;
- $temp = explode('/',$_SERVER['REQUEST_URI']);
- $slug = $temp[2];
- $res_check = mysqli_query($conn,"select * from azonics_modules where module_controller='".$slug."' and module_status='1';");
- if (mysqli_num_rows($res_check)>0) {
- $row_check = mysqli_fetch_array($res_check);
- if ($row_check['module_display_parent']==$moduleID) {
- return ' active';
- }
- else {
- return '';
- }
- }
- else {
- return '';
- }
- }
-
-
- static function reloadAccount() {
- self::dbconnect();
- global $conn;
- if ($_SESSION['admin_user']->admin_id!='') {
- $res = mysqli_query($conn,"select * from azonics_admin_users where admin_id='".$_SESSION['admin_user']->admin_id."';");
- if (mysqli_num_rows($res)>0) {
- $_SESSION['admin_user'] = mysqli_fetch_object($res);
- return true;
- }
- else {
- return false;
- }
- }
- else {
- return false;
- }
- }
-
-
- static function isLanguageModuleEnabled($admin_id='') {
- self::dbconnect();
- global $conn;
- if ($admin_id!='') {
- $res_module_access = mysqli_query($conn,"select * from "
- . "azonics_modules, "
- . "azonics_modules_role, "
- . "azonics_admin_users where "
- . "module_controller='translator' and "
- . "module_status='1' and "
- . "admin_id='".$admin_id."' and "
- . "admin_status<>'0' and "
- . "modrole_role_id=admin_access_level and "
- . "modrole_module_id=module_id and "
- . "modrole_status='1';");
- if (mysqli_num_rows($res_module_access)>0) {
- return true;
- }
- else {
- return false;
- }
- }
- else {
- return false;
- }
- }
-
-
- static function loadSystemSettings() {
- self::dbconnect();
- global $conn;
- $res = mysqli_query($conn,"select * from azonics_settings where setting_status='1';");
- if (mysqli_num_rows($res)>0) {
- while ($row = mysqli_fetch_object($res)) {
- $hash = $row->setting_name;
- $data[$hash] = $row;
- }
- return $data;
- }
- else {
- return false;
- }
- }
-
- static function getSystemParam($paramName='') {
- self::dbconnect();
- global $conn;
- $res = mysqli_query($conn,"select * from azonics_settings where setting_name='".$paramName."';");
- if (mysqli_num_rows($res)>0) {
- $row = mysqli_fetch_object($res);
- if ($_SESSION['admin_lang'] == 'hu') {
- return $row->setting_value_text;
- }
- else {
- return $row->setting_value_text;
- }
- }
- else {
- return false;
- }
- }
- static function getAccessLevelName($level_id='') {
- self::dbconnect();
- global $conn;
- if ($level_id!='') {
- $res = mysqli_query($conn,"select * from azonics_roles where role_id='".$level_id."';");
- if (mysqli_num_rows($res)>0) {
- $row = mysqli_fetch_array($res);
- return '<span class="'.$row['role_color'].'">'.$row['role_name'].'</span>';
- }
- else {
- return '';
- }
- }
- else {
- return '';
- }
- }
-
-
- static function checkForUpdates() {
- global $config;
- $update_xml_file = file_get_contents('http://updates.kreatio.hu/updates.php?key='.$config['licence_key']);
- $update_xml = file_get_contents($update_xml_file);
-
- if ($update_xml!='') {
- $dom = simplexml_load_string($update_xml);
- $ftp = ftp_connect('ftp.kreatio.hu');
- $login = ftp_login($ftp,'updates@kreatio.hu','zTaD[fIGpgCI');
- foreach ($dom->file as $file) {
- ftp_get($ftp,$file['path'],$file['path'],FTP_ASCII);
- }
- return $dom->message;
- }
- else {
- return '';
- }
- }
-
-
- static function getSiteName($default='') {
- self::dbconnect();
- global $conn;
- $res = mysqli_query($conn,"select * from azonics_settings where setting_name='SITENAME' and setting_status='1';");
- if (mysqli_num_rows($res)>0) {
- $row = mysqli_fetch_array($res);
- return $row['setting_value_text'];
- }
- else {
- return $default;
- }
- }
-
- static function getPageName() {
- self::dbconnect();
- global $conn;
- $res = mysqli_query($conn,"select * from azonics_settings where setting_name='PAGENAME' and setting_status='1';");
- if (mysqli_num_rows($res)>0) {
- $row = mysqli_fetch_array($res);
- return $row['setting_value_text'];
- }
- else {
- return '';
- }
- }
-
-
- static function getBaseColorScheme($default='') {
- self::dbconnect();
- global $conn;
- $res = mysqli_query($conn,"select * from azonics_settings where setting_name='COLOR' and setting_status='1';");
- if (mysqli_num_rows($res)>0) {
- $row = mysqli_fetch_array($res);
- return $row['setting_value_text'];
- }
- else {
- return $default;
- }
- }
-
-
- static function getSlogan($default='') {
- self::dbconnect();
- global $conn;
- $res = mysqli_query($conn,"select * from azonics_settings where setting_name='SLOGAN' and setting_status='1';");
- if (mysqli_num_rows($res)>0) {
- $row = mysqli_fetch_array($res);
- return $row['setting_value_text'];
- }
- else {
- return $default;
- }
- }
-
-
- static function userComboBox($sel='') {
- self::dbconnect();
- global $conn;
- $res = mysqli_query($conn,"select * from azonics_users where user_status<>'0' order by user_nick asc;");
-
- $result = '<option value="">'.lang::_('Choose user').'</option>';
-
- if (mysqli_num_rows($res)>0) {
- while ($row = mysqli_fetch_array($res)) {
- if ($sel==$row['user_id']) {
- $result.= '<option value="'.$row['user_id'].'" selected>'.$row['user_nick'].' ('.$row['user_first_name'].' '.$row['user_last_name'].')</option>';
- }
- else {
- $result.= '<option value="'.$row['user_id'].'">'.$row['user_nick'].' ('.$row['user_first_name'].' '.$row['user_last_name'].')</option>';
- }
- }
- }
-
- return $result;
- }
-
-
- static function getUserNameByID($user_id='') {
- self::dbconnect();
- global $conn;
- $user_id = mysql_real_escape_string($user_id);
- $res = mysqli_query($conn,"select * from azonics_users where user_id='".$user_id."';");
- if (mysqli_num_rows($res)>0) {
- $row = mysqli_fetch_array($res);
- return $row['user_first_name'].' '.$row['user_last_name'].' ('.$row['user_nick'].')';
- }
- else {
- return false;
- }
- }
-
-
- static function categoryComboBox($sel='') {
- self::dbconnect();
- global $conn;
- $res = mysqli_query($conn,"select * from azonics_categories where category_status<>'0' order by category_name asc;");
-
- $result = '<option value="">'.lang::_('Choose category').'</option>';
-
- if (mysqli_num_rows($res)>0) {
- while ($row = mysqli_fetch_array($res)) {
- if ($sel==$row['category_id']) {
- $result.= '<option value="'.$row['category_id'].'" selected>'.$row['category_name'].'</option>';
- }
- else {
- $result.= '<option value="'.$row['category_id'].'">'.$row['category_name'].'</option>';
- }
- }
- }
-
- return $result;
- }
-
-
- static function getProfileCategory($id='') {
- self::dbconnect();
- global $conn;
- if ($id!='') {
- $res = mysqli_query($conn,"select * from azonics_categories where category_id='".$id."';");
- $row = mysqli_fetch_array($res);
- return $row['category_name'];
- }
- else {
- return false;
- }
- }
-
-
- static function getProductStatus($status='',$pid='') {
- if ($status=='1') {
- return '<div class="btn-group">'
- . '<button type="button" class="btn btn-success">'.lang::_('Active').'</button>'
- . '<button aria-expanded="false" type="button" class="btn btn-success dropdown-toggle" data-toggle="dropdown">'
- . '<span class="caret"></span>'
- . '<span class="sr-only">Toggle Dropdown</span>'
- . '</button>'
- . '<ul class="dropdown-menu" role="menu">'
- . '<li><a href="/admin/products/set/?status=3&id='.$pid.'">'.lang::_('Set inactive').'</a></li>'
- . '<li><a href="/admin/products/delete/?id='.$pid.'">'.lang::_('Delete').'</a></li>'
- . '</ul>'
- . '</div>';
- }
- else if ($status=='3') {
- return '<div class="btn-group">'
- . '<button type="button" class="btn btn-default">'.lang::_('Inactive').'</button>'
- . '<button aria-expanded="false" type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">'
- . '<span class="caret"></span>'
- . '<span class="sr-only">Toggle Dropdown</span>'
- . '</button>'
- . '<ul class="dropdown-menu" role="menu">'
- . '<li><a href="/admin/products/set/?status=1&id='.$pid.'">'.lang::_('Set active').'</a></li>'
- . '<li><a href="/admin/products/delete/?id='.$pid.'">'.lang::_('Delete').'</a></li>'
- . '</ul>'
- . '</div>';
- }
- }
-
-
- static function getProfileStatus($status='',$pid='') {
- if ($status=='1') {
- return '<div class="btn-group">'
- . '<button type="button" class="btn btn-xs btn-success">'.lang::_('Active').'</button>'
- . '<button aria-expanded="false" type="button" class="btn btn-success btn-xs dropdown-toggle" data-toggle="dropdown">'
- . '<span class="caret"></span>'
- . '<span class="sr-only">Toggle Dropdown</span>'
- . '</button>'
- . '<ul class="dropdown-menu" role="menu">'
- . '<li><a href="/admin/profiles/set/?status=2&id='.$pid.'">'.lang::_('Set inactive').'</a></li>'
- . '<li><a href="/admin/profiles/delete/?id='.$pid.'">'.lang::_('Delete').'</a></li>'
- . '</ul>'
- . '</div>';
- }
- else if ($status=='2') {
- return '<div class="btn-group">'
- . '<button type="button" class="btn btn-xs btn-default">'.lang::_('Inactive').'</button>'
- . '<button aria-expanded="false" type="button" class="btn btn-default btn-xs dropdown-toggle" data-toggle="dropdown">'
- . '<span class="caret"></span>'
- . '<span class="sr-only">Toggle Dropdown</span>'
- . '</button>'
- . '<ul class="dropdown-menu" role="menu">'
- . '<li><a href="/admin/profiles/set/?status=1&id='.$pid.'">'.lang::_('Set active').'</a></li>'
- . '<li><a href="/admin/profiles/delete/?id='.$pid.'">'.lang::_('Delete').'</a></li>'
- . '</ul>'
- . '</div>';
- }
- else if ($status=='3') {
- return '<div class="btn-group">'
- . '<button type="button" class="btn btn-xs btn-info">'.lang::_('Waiting').'</button>'
- . '<button aria-expanded="false" type="button" class="btn btn-info btn-xs dropdown-toggle" data-toggle="dropdown">'
- . '<span class="caret"></span>'
- . '<span class="sr-only">Toggle Dropdown</span>'
- . '</button>'
- . '<ul class="dropdown-menu" role="menu">'
- . '<li><a href="/admin/profiles/set/?status=1&id='.$pid.'">'.lang::_('Enable').'</a></li>'
- . '<li><a href="/admin/profiles/delete/?id='.$pid.'">'.lang::_('Delete').'</a></li>'
- . '</ul>'
- . '</div>';
- }
- }
-
-
- static function getMainImage($pid) {
- self::dbconnect();
- global $conn;
-
- $res2 = mysqli_query($conn,"select * from azonics_galeries where "
- . "galery_design_id='".$pid."' and "
- . "galery_status='1' and galery_main_image='1';");
- if (mysqli_num_rows($res2)>0) {
- $row2 = mysqli_fetch_array($res2);
- return '<img src="'.BASE_URL.$row2['galery_image'].'" alt="Image" />';
- }
- else {
- return '<img src="http://placehold.it/500x500" alt="Image" />';
- }
- }
-
-
- static function battleTypesOptions($sel='') {
- self::dbconnect();
- global $conn;
- $res_bt = mysqli_query($conn,"select * from azonics_battle_types where "
- . "battle_type_status='1' "
- . "order by battle_type_name asc;");
-
- $temp = '<option value="">Choose battle type</option>';
-
- if (mysqli_num_rows($res_bt)>0) {
- while ($row_bt = mysqli_fetch_array($res_bt)) {
- if ($sel==$row_bt['battle_type_id']) {
- $temp.= '<option value="'.$row_bt['battle_type_id'].'" selected>'.$row_bt['battle_type_name'].'</option>';
- }
- else {
- $temp.= '<option value="'.$row_bt['battle_type_id'].'">'.$row_bt['battle_type_name'].'</option>';
- }
- }
- }
-
- return $temp;
- }
-
-
- static function battleAwardsOptions($sel='') {
- self::dbconnect();
- global $conn;
- $res_bw = mysqli_query($conn,"select * from azonics_awards where "
- . "award_status='1' "
- . "order by award_name asc;");
-
- $temp = '<option value="">Choose award</option>';
-
- if (mysqli_num_rows($res_bw)>0) {
- while ($row_bw = mysqli_fetch_array($res_bw)) {
- if ($sel==$row_bw['award_id']) {
- $temp.= '<option value="'.$row_bw['award_id'].'" selected>'.$row_bw['award_name'].'</option>';
- }
- else {
- $temp.= '<option value="'.$row_bw['award_id'].'">'.$row_bw['award_name'].'</option>';
- }
- }
- }
-
- return $temp;
- }
-
-
- static function getBattleType($type_id='') {
- self::dbconnect();
- global $conn;
- if ($type_id!='') {
- $res_type = mysqli_query($conn,"select * from azonics_battle_types where battle_type_id='".$type_id."';");
- if (mysqli_num_rows($res_type)>0) {
- $row_type = mysqli_fetch_array($res_type);
- return $row_type['battle_type_name'];
- }
- else {
- return false;
- }
- }
- else {
- return false;
- }
- }
-
- static function getBattleAward($award_id='') {
- self::dbconnect();
- global $conn;
- if ($award_id!='') {
- $res_award = mysqli_query($conn,"select * from azonics_awards where award_id='".$award_id."';");
- if (mysqli_num_rows($res_award)>0) {
- $row_award = mysqli_fetch_array($res_award);
- return $row_award['award_name'];
- }
- else {
- return false;
- }
- }
- else {
- return false;
- }
- }
-
-
- static function generateSlug($name='') {
- if ($name!='') {
- $text = preg_replace('~[^\\pL\d]+~u', '-', $text);
- $text = trim($text, '-');
- $text = iconv('utf-8', 'us-ascii//TRANSLIT', $text);
- $text = strtolower($text);
- $text = preg_replace('~[^-\w]+~', '', $text);
-
- if (empty($text)) return time();
-
- return $text;
- }
- else {
- return time();
- }
- }
-
-
- static function getProductTags($product_category='') {
- $tags = explode(",",$product_category);
- foreach ($tags as $tag) {
- if ($tag!='') $list.= '<span class="label label-info">'.$tag.'</span> ';
- }
-
- return $list;
- }
-
-
- static function getProductMeta($product_id='') {
- self::dbconnect();
- global $conn;
- $list = '';
-
- if ($product_id!='') {
- $res = mysqli_query($conn,"select * from azonics_product_meta where "
- . "meta_pid='".$product_id."' and "
- . "meta_status='1' order by meta_date asc;");
-
- if (mysqli_num_rows($res)>0) {
- while ($row = mysqli_fetch_array($res)) {
- $list.= '<!--Metarow:'.$row['meta_id'].'-->'
- . '<tr>'
- . '<td><input type="text" name="meta_key" onblur="save_product_meta_data($(this))" value="'.$row['meta_key'].'" class="form-control" data-mid="'.$row['meta_id'].'" /></td>'
- . '<td><input type="text" name="meta_value" onblur="save_product_meta_data($(this))" value="'.$row['meta_value'].'" class="form-control" data-mid="'.$row['meta_id'].'" /></td>'
- . '<td><button type="button" name="meta_delete" class="btn btn-danger" data-mid="'.$row['meta_id'].'" data-pid="'.$row['meta_pid'].'" onclick="delete_product_meta($(this))"><i class="fa fa-trash"></i></button></td>'
- . '</tr>';
- }
- }
- }
-
- return $list;
- }
-
- static function bannerZones($selectedZone='') {
- $temp = '<option value="">'.lang::_('Choose banner zone!').'</option>';
-
- if ($selectedZone=='zone1') {
- $temp.= '<option value="zone1" selected>'.lang::_('Főoldali slider').'</option>';
- }
- else {
- $temp.= '<option value="zone1">'.lang::_('Főoldali slider').'</option>';
- }
-
- return $temp;
- }
-
-
- static function getBannerZoneName($zone_id) {
- if ($zone_id=='zone1') {
- return lang::_('Speciális kínálat');
- }
- else {
- return lang::_('Rólunk mondták');
- }
- }
-
-
- static function trim_url($url) {
- if ($url!='') {
- $url = str_replace("http://","",$url);
- }
-
- return $url;
- }
-
-
- static function add_url_prefix($url) {
- if ($url!='') {
- $url = "http://".$url;
- }
-
- return $url;
- }
-
-
- static function get_category_selector($selected) {
- self::dbconnect();
- global $conn;
- $res = mysqli_query($conn,"select * from azonics_categories where category_status='0' order by category_name asc;");
-
- $options = '';
-
- if (mysqli_num_rows($res)>0) {
- while ($row = mysqli_fetch_object($res)) {
- if ($_SESSION['category']=='') $_SESSION['category'] = $row->category_id;
-
- if ($selected==$row->category_id) {
- $options.= '<option value="'.$row->category_id.'" selected>'.$row->category_name.'</option>';
- }
- else {
- $options.= '<option value="'.$row->category_id.'">'.$row->category_name.'</option>';
- }
- }
- }
-
- if ($_SESSION['category']=='') $_SESSION['category'] = '0';
-
- $options.= '<option value="0">'.lang::_('Minden kategória').'</option>';
-
- return $options;
- }
-
-
- static function getLendingStatusByID($status_id='1',$field='ls_name') {
- self::dbconnect();
- global $conn;
- if ($status_id!='') {
- $res_item = mysqli_query($conn,"select * from mingo_lending_status where ls_id='".$status_id."';");
- $row_item = mysqli_fetch_array($res_item);
- return $row_item[$field];
- }
- else {
- return false;
- }
- }
-
-
- static function getLendingStatusCombo($selected='1',$lending_id='') {
- self::dbconnect();
- global $conn;
- $res = mysqli_query($conn,"select * from mingo_lending_status where ls_status='1' order by ls_id asc;");
- if ($selected=='') $selected='1';
-
- $result = '<div class="btn-group">';
- $result.= '<button type="button" class="btn '.self::getLendingStatusByID($selected,'ls_color').'">'.self::getLendingStatusByID($selected,'ls_name').'</button>';
- $result.= '<button aria-expanded="false" type="button" class="btn '.self::getLendingStatusByID($selected,'ls_color').' dropdown-toggle" data-toggle="dropdown">
- <span class="caret"></span>
- <span class="sr-only">Toggle Dropdown</span>
- </button>
- <ul class="dropdown-menu" role="menu">';
-
- if (mysqli_num_rows($res)>0) {
- while ($row = mysqli_fetch_array($res)) {
- $result.= '<li><a href="/admin/lendings/set/?status='.$row['ls_id'].'&lending_id='.$lending_id.'">'.$row['ls_name'].'</a></li>';
- }
- }
-
- $result.= '</ul></div>';
-
- return $result;
- }
-
-
- static function lendingStatusComboBox($selected='') {
- self::dbconnect();
- global $conn;
- $res = mysqli_query($conn,"select * from mingo_lending_status where ls_status='1' order by ls_id asc;");
- if (mysqli_num_rows($res)>0) {
- while ($row = mysqli_fetch_array($res)) {
- if ($selected==$row['ls_id']) {
- $result.= '<option value="'.$row['ls_id'].'" selected>'.$row['ls_name'].'</option>';
- }
- else {
- $result.= '<option value="'.$row['ls_id'].'">'.$row['ls_name'].'</option>';
- }
- }
- }
- else {
- $result.= '<option value="0">Nem lehet státuszt állítani!</option>';
- }
-
- return $result;
- }
-
- static function get_todos($show_all='all',$uid=0,$lending_id=0,$limit=10,$orderby='todo_date',$order='asc',$comments=false,$finished=true) {
- self::dbconnect();
- global $conn;
- if ($comments==true) {
- $comments_selector = " and todo_date<>'NULL'";
- }
- else {
- $comments_selector = '';
- }
- if ($finished==false) {
- $finish = " and todo_finished<>'1'";
- }
- else {
- $finish = "";
- }
- if ($show_all=='all') {
- $res = mysqli_query($conn,"select * from mingo_todos where todo_status='1'".$comments_selector." and todo_admin_id='".$_SESSION['admin_user']->admin_id."'".$finish." order by ".$orderby." ".$order." limit 0,".$limit.";");
- }
- elseif ($show_all=='users') {
- $res = mysqli_query($conn,"select * from mingo_todos where todo_status='1'".$comments_selector." and todo_user_id<>'0' and todo_admin_id='".$_SESSION['admin_user']->admin_id."'".$finish." order by ".$orderby." ".$order." limit 0,".$limit.";");
- }
- elseif ($show_all=='lendings') {
- $res = mysqli_query($conn,"select * from mingo_todos where todo_status='1'".$comments_selector." and todo_lending_id<>'0' and todo_admin_id='".$_SESSION['admin_user']->admin_id."'".$finish." order by ".$orderby." ".$order." limit 0,".$limit.";");
- }
- elseif ($uid>0) {
- $res = mysqli_query($conn,"select * from mingo_todos where todo_status='1'".$comments_selector." and todo_user_id='".$uid."' and todo_admin_id='".$_SESSION['admin_user']->admin_id."'".$finish." order by ".$orderby." ".$order." limit 0,".$limit.";");
- }
- elseif ($lending_id>0) {
- $res = mysqli_query($conn,"select * from mingo_todos where todo_status='1'".$comments_selector." and todo_lending_id='".$lending_id."' and todo_admin_id='".$_SESSION['admin_user']->admin_id."'".$finish." order by ".$orderby." ".$order." limit 0,".$limit.";");
- }
- if (mysqli_num_rows($res)>0) {
- while ($row = mysqli_fetch_object($res)) {
- $result[] = $row;
- }
- return $result;
- }
- else {
- return false;
- }
- }
- function get_todo_object($id) {
- self::dbconnect();
- global $conn;
- $res = mysqli_query($conn,"select * from mingo_todos where todo_id='".$id."';");
- if (mysqli_num_rows($res)>0) {
- return mysqli_fetch_object($res);
- }
- else {
- return false;
- }
- }
-
-
-
- function get_group_options($group,$selected='') {
- self::dbconnect();
- global $conn;
- $res = mysqli_query($conn,"SELECT * FROM sc_variants WHERE variant_group='".$group."' AND variant_status='1' ORDER BY variant_name ASC;");
-
- $result = '<option value="">Válasszon!</option>';
-
- if (mysqli_num_rows($res)>0) {
- while ($row = mysqli_fetch_array($res)) {
- if ($selected==$row['variant_id']) {
- $result.= '<option value="'.$row['variant_id'].'" selected>'.$row['variant_name'].'</option>';
- }
- else {
- $result.= '<option value="'.$row['variant_id'].'">'.$row['variant_name'].'</option>';
- }
- }
- }
-
- return $result;
- }
-
- function get_rajz($cikkszam='') {
- self::dbconnect();
- global $conn;
- if ($cikkszam!='') {
- $res = mysqli_query($conn,"select * from sc_rajzok where rajz_cikkszam='".$cikkszam."' and rajz_status='1';");
- if (mysqli_num_rows($res)>0) {
- $row = mysqli_fetch_array($res);
- return $row['rajz_file'];
- }
- else {
- return false;
- }
- }
- else {
- return false;
- }
- }
-
-
- function has_rajz($cikkszam='') {
- self::dbconnect();
- global $conn;
- if ($cikkszam!='') {
- $res = mysqli_query($conn,"select * from sc_rajzok where rajz_cikkszam='".$cikkszam."' and rajz_status='1';");
- if (mysqli_num_rows($res)>0) {
- return true;
- }
- else {
- return false;
- }
- }
- else {
- return false;
- }
- }
-
-
- function has_document($id) {
- self::dbconnect();
- global $conn;
- if ($id!='') {
- $res = mysqli_query($conn,"select * from sc_beszerzes where beszer_id='".$id."';");
- if (mysqli_num_rows($res)>0) {
- $row = mysqli_fetch_array($res);
- return $row['beszer_document'];
- }
- else {
- return false;
- }
- }
- else {
- return false;
- }
- }
-
-
- function has_bill_image($bill_number='') {
- self::dbconnect();
- global $conn;
- if ($bill_number!='') {
- $res = mysqli_query($conn,"select * from sc_bills where bill_number='".$bill_number."' and bill_status='1';");
- if (mysqli_num_rows($res)>0) {
- return true;
- }
- else {
- return false;
- }
- }
- else {
- return false;
- }
- }
-
-
- function get_bill_image($bill_number='') {
- self::dbconnect();
- global $conn;
- if ($bill_number!='') {
- $res = mysqli_query($conn,"select * from sc_bills where bill_number='".$bill_number."' and bill_status='1';");
- if (mysqli_num_rows($res)>0) {
- $row = mysqli_fetch_array($res);
- return $row['bill_image'];
- }
- else {
- return false;
- }
- }
- else {
- return false;
- }
- }
-
- function check_admin_access_to_action() {
- if ($_SESSION['admin_user']->admin_access_level=='1' || $_SESSION['admin_user']->admin_access_level=='11') {
- return true;
- }
- else {
- return false;
- }
- }
-
-
- function get_modules_select($selected='') {
- self::dbconnect();
- global $conn;
- $res = mysqli_query($conn,"SELECT * FROM azonics_modules WHERE module_status='1' ORDER BY display_order ASC;");
- $result = '';
- if (mysqli_num_rows($res)>0) {
- while ($row = mysqli_fetch_array($res)) {
- if ($selected==$row['module_controller']) {
- $result.= '<option value="'.$row['module_controller'].'" selected>'.$row['module_name'].'</option>';
- }
- else {
- $result.= '<option value="'.$row['module_controller'].'">'.$row['module_name'].'</option>';
- }
- }
- }
-
- return $result;
- }
-
-
- static function get_product_data($pid) {
- self::dbconnect();
- global $conn;
- if ($pid!=='') {
- $res = mysqli_query($conn,"SELECT * FROM products_temp WHERE id='".$pid."';");
- if (mysqli_num_rows($res)>0) {
- $row = mysqli_fetch_object($res);
- $result = 'Termék név: '.$row->name.'<br>Brand: '.$row->brand.'<br>Part.no.: '.$row->part_no.'<br>Short desc.: '.$row->short_description.'<br>Price: '.$row->price.'<br>Type: '.$row->type;
- return $result;
- }
- else {
- return false;
- }
- }
- else {
- return false;
- }
- }
-
-
- static function get_product_image($pid,$type) {
- self::dbconnect();
- global $conn;
- if ($pid!=='' && $type!=='') {
- $res = mysqli_query($conn,"SELECT * FROM products_temp WHERE id='".$pid."';");
- if (mysqli_num_rows($res)>0) {
- $row = mysqli_fetch_object($res);
- if ($row->$type!==NULL) {
- $result = '<img src="http://webshop.rackmester.hu/'.$row->$type.'" style="width: 50px;" />';
- }
- else {
- $result = ' - ';
- }
- return $result;
- }
- else {
- return false;
- }
- }
- else {
- return false;
- }
- }
-
-
- static function get_ertekkeszlet($kategoria,$mezo) {
- self::dbconnect();
- global $conn;
- if ($kategoria!=='' && $mezo!=='') {
- $res = mysqli_query($conn,"SELECT * FROM azonics_codomains WHERE kategoria='".$kategoria."' AND mezo='".$mezo."' AND status='1' ORDER BY ertek ASC;");
- if (mysqli_num_rows($res)>0) {
- while ($row = mysqli_fetch_array($res)) {
- $result[] = $row['ertek'];
- }
- return $result;
- }
- else {
- return false;
- }
- }
- else {
- return false;
- }
- }
-
-
- static function get_category_factor($category) {
- self::dbconnect();
- global $conn;
- if ($category!='') {
- $res = mysqli_query($conn,"SELECT * FROM azonics_category_price_factors WHERE category='".$category."' AND status='1';");
- if (mysqli_num_rows($res)>0) {
- return mysqli_fetch_object($res);
- }
- else {
- return false;
- }
- }
- else {
- return false;
- }
- }
- static function get_velemenyek_by_agent_id($agentid) {
- self::dbconnect();
- global $conn;
- if ($agentid!='') {
- $res = mysqli_query($conn,"SELECT * FROM velemenyek WHERE agent_id='".$agentid."';");
- return mysqli_num_rows($res);
- }
- else {
- return 0;
- }
- }
-
-
- }
|