admin_utils.php 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218
  1. <?php
  2. class admin_utils {
  3. static function dbconnect() {
  4. global $config;
  5. global $conn;
  6. $conn = mysqli_connect($config['db_host'],$config['db_username'],$config['db_password'],$config['db_name']);
  7. mysqli_query($conn,"SET NAMES utf8");
  8. mysqli_set_charset($conn, 'utf8mb4');
  9. return true;
  10. }
  11. static function getText($id, $field) {
  12. self::dbconnect();
  13. global $conn;
  14. $res = mysqli_query($conn,"SELECT * FROM azonics_text_pages WHERE page_id='".$id."';");
  15. if (mysqli_num_rows($res)>0) {
  16. $row = mysqli_fetch_array($res);
  17. $text = $row[$field];
  18. $text = str_replace("<div>","",$text);
  19. $text = str_replace("</div>","",$text);
  20. $text = str_replace("<p>","",$text);
  21. $text = str_replace("</p>","",$text);
  22. $text = str_replace("<span>","",$text);
  23. $text = str_replace("</span>","",$text);
  24. return $text;
  25. }
  26. else {
  27. return 'No data available';
  28. }
  29. }
  30. static function getAdminName() {
  31. return $_SESSION['admin_user']->admin_real_name;
  32. }
  33. static function getAdminAccessLevels($selected='') {
  34. self::dbconnect();
  35. global $conn;
  36. $result = mysqli_query($conn,"select * from azonics_roles where role_status='1' order by role_name asc;");
  37. $temp = '<option value="">'.lang::_('Please select admin user access level...').'</option>';
  38. if (mysqli_num_rows($result)>0) {
  39. while ($row = mysqli_fetch_array($result)) {
  40. if ($_SESSION['access_level'] == 11) {
  41. if ($selected==$row['role_id']) {
  42. $temp.= '<option value="'.$row['role_id'].'" selected>'.$row['role_name'].'</option>';
  43. }
  44. else {
  45. $temp.= '<option value="'.$row['role_id'].'">'.$row['role_name'].'</option>';
  46. }
  47. }
  48. else if ($_SESSION['access_level'] == 13) {
  49. if ($row['role_id'] == 14) {
  50. $temp.= '<option value="'.$row['role_id'].'" selected>'.$row['role_name'].'</option>';
  51. }
  52. }
  53. }
  54. }
  55. else {
  56. $temp.= '<option value="">'.lang::_('Actually no active role group...').'</option>';
  57. }
  58. return $temp;
  59. }
  60. static function getUserTypes($selected='') {
  61. self::dbconnect();
  62. global $conn;
  63. $result = mysqli_query($conn,"select * from azonics_user_types where user_type_status='1' order by user_type_name asc;");
  64. $temp = '<option value="">'.lang::_('Please select user type...').'</option>';
  65. if (mysqli_num_rows($result)>0) {
  66. while ($row = mysqli_fetch_array($result)) {
  67. if ($selected==$row['user_type_id']) {
  68. $temp.= '<option value="'.$row['user_type_id'].'" selected>'.$row['user_type_name'].'</option>';
  69. }
  70. else {
  71. $temp.= '<option value="'.$row['user_type_id'].'">'.$row['user_type_name'].'</option>';
  72. }
  73. }
  74. }
  75. else {
  76. $temp.= '<option value="">'.lang::_('Actually no active user type...').'</option>';
  77. }
  78. return $temp;
  79. }
  80. static function getUserTypeName($type='') {
  81. self::dbconnect();
  82. global $conn;
  83. if ($type!='') {
  84. $result = mysqli_query($conn,"select * from azonics_user_types where user_type_id='".$type."';");
  85. if (mysqli_num_rows($result)>0) {
  86. $row = mysqli_fetch_array($result);
  87. return '<span class="'.$row['user_type_color'].'">'.$row['user_type_name'].'</span>';
  88. }
  89. else {
  90. return false;
  91. }
  92. }
  93. else {
  94. return false;
  95. }
  96. }
  97. static function getUserState($user_id='') {
  98. self::dbconnect();
  99. global $conn;
  100. if ($user_id!='') {
  101. $result = mysqli_query($conn,"select * from users where id='".$user_id."';");
  102. if (mysqli_num_rows($result)>0) {
  103. $row = mysqli_fetch_array($result);
  104. if ($row['status']=='1') {
  105. return ' checked';
  106. }
  107. else {
  108. return '';
  109. }
  110. }
  111. else {
  112. return '';
  113. }
  114. }
  115. else {
  116. return '';
  117. }
  118. }
  119. static function getUserName($user_id='') {
  120. self::dbconnect();
  121. global $conn;
  122. if ($user_id!='') {
  123. $result = mysqli_query($conn,"select * from azonics_users where user_id='".$user_id."';");
  124. if (mysqli_num_rows($result)>0) {
  125. $row = mysqli_fetch_array($result);
  126. return $row['user_first_name']." ".$row['user_last_name'];
  127. }
  128. else {
  129. return '';
  130. }
  131. }
  132. else {
  133. return '';
  134. }
  135. }
  136. static function getUserDefaultMailerState($user_id='') {
  137. self::dbconnect();
  138. global $conn;
  139. if ($user_id!='') {
  140. $result = mysqli_query($conn,"select * from azonics_users where user_id='".$user_id."';");
  141. if (mysqli_num_rows($result)>0) {
  142. $row = mysqli_fetch_array($result);
  143. if ($row['user_default_mailer_status']=='1') {
  144. return ' checked';
  145. }
  146. else {
  147. return '';
  148. }
  149. }
  150. else {
  151. return '';
  152. }
  153. }
  154. else {
  155. return '';
  156. }
  157. }
  158. static function checkAdminAccessToModule($module='') {
  159. self::dbconnect();
  160. global $conn;
  161. if ($module!='') {
  162. $result = mysqli_query($conn,"select * from azonics_modules_role where "
  163. . "modrole_role_id='".$_SESSION['admin_user']->admin_access_level."' and "
  164. . "modrole_module_id='".$module."' and "
  165. . "modrole_status='1';");
  166. if (mysqli_num_rows($result)>0) {
  167. return true;
  168. }
  169. else {
  170. return false;
  171. }
  172. }
  173. else {
  174. return false;
  175. }
  176. }
  177. static function getMenu($parent=0) {
  178. self::dbconnect();
  179. global $conn;
  180. $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());
  181. $resultObjects = null;
  182. if (mysqli_num_rows($result)>0) {
  183. while($row = mysqli_fetch_object($result)) {
  184. if (self::checkAdminAccessToModule($row->module_id)) {
  185. $resultObjects[] = $row;
  186. }
  187. }
  188. return $resultObjects;
  189. }
  190. else {
  191. return $resultObjects;
  192. }
  193. }
  194. static function checkMenuActive($slug='') {
  195. if (stristr($_SERVER['REQUEST_URI'],$slug)) {
  196. return ' active';
  197. }
  198. else {
  199. return '';
  200. }
  201. }
  202. static function checkSubmenuActive($moduleID='') {
  203. self::dbconnect();
  204. global $conn;
  205. $temp = explode('/',$_SERVER['REQUEST_URI']);
  206. $slug = $temp[2];
  207. $res_check = mysqli_query($conn,"select * from azonics_modules where module_controller='".$slug."' and module_status='1';");
  208. if (mysqli_num_rows($res_check)>0) {
  209. $row_check = mysqli_fetch_array($res_check);
  210. if ($row_check['module_display_parent']==$moduleID) {
  211. return ' active';
  212. }
  213. else {
  214. return '';
  215. }
  216. }
  217. else {
  218. return '';
  219. }
  220. }
  221. static function reloadAccount() {
  222. self::dbconnect();
  223. global $conn;
  224. if ($_SESSION['admin_user']->admin_id!='') {
  225. $res = mysqli_query($conn,"select * from azonics_admin_users where admin_id='".$_SESSION['admin_user']->admin_id."';");
  226. if (mysqli_num_rows($res)>0) {
  227. $_SESSION['admin_user'] = mysqli_fetch_object($res);
  228. return true;
  229. }
  230. else {
  231. return false;
  232. }
  233. }
  234. else {
  235. return false;
  236. }
  237. }
  238. static function isLanguageModuleEnabled($admin_id='') {
  239. self::dbconnect();
  240. global $conn;
  241. if ($admin_id!='') {
  242. $res_module_access = mysqli_query($conn,"select * from "
  243. . "azonics_modules, "
  244. . "azonics_modules_role, "
  245. . "azonics_admin_users where "
  246. . "module_controller='translator' and "
  247. . "module_status='1' and "
  248. . "admin_id='".$admin_id."' and "
  249. . "admin_status<>'0' and "
  250. . "modrole_role_id=admin_access_level and "
  251. . "modrole_module_id=module_id and "
  252. . "modrole_status='1';");
  253. if (mysqli_num_rows($res_module_access)>0) {
  254. return true;
  255. }
  256. else {
  257. return false;
  258. }
  259. }
  260. else {
  261. return false;
  262. }
  263. }
  264. static function loadSystemSettings() {
  265. self::dbconnect();
  266. global $conn;
  267. $res = mysqli_query($conn,"select * from azonics_settings where setting_status='1';");
  268. if (mysqli_num_rows($res)>0) {
  269. while ($row = mysqli_fetch_object($res)) {
  270. $hash = $row->setting_name;
  271. $data[$hash] = $row;
  272. }
  273. return $data;
  274. }
  275. else {
  276. return false;
  277. }
  278. }
  279. static function getSystemParam($paramName='') {
  280. self::dbconnect();
  281. global $conn;
  282. $res = mysqli_query($conn,"select * from azonics_settings where setting_name='".$paramName."';");
  283. if (mysqli_num_rows($res)>0) {
  284. $row = mysqli_fetch_object($res);
  285. if ($_SESSION['admin_lang'] == 'hu') {
  286. return $row->setting_value_text;
  287. }
  288. else {
  289. return $row->setting_value_text;
  290. }
  291. }
  292. else {
  293. return false;
  294. }
  295. }
  296. static function getAccessLevelName($level_id='') {
  297. self::dbconnect();
  298. global $conn;
  299. if ($level_id!='') {
  300. $res = mysqli_query($conn,"select * from azonics_roles where role_id='".$level_id."';");
  301. if (mysqli_num_rows($res)>0) {
  302. $row = mysqli_fetch_array($res);
  303. return '<span class="'.$row['role_color'].'">'.$row['role_name'].'</span>';
  304. }
  305. else {
  306. return '';
  307. }
  308. }
  309. else {
  310. return '';
  311. }
  312. }
  313. static function checkForUpdates() {
  314. global $config;
  315. $update_xml_file = file_get_contents('http://updates.kreatio.hu/updates.php?key='.$config['licence_key']);
  316. $update_xml = file_get_contents($update_xml_file);
  317. if ($update_xml!='') {
  318. $dom = simplexml_load_string($update_xml);
  319. $ftp = ftp_connect('ftp.kreatio.hu');
  320. $login = ftp_login($ftp,'updates@kreatio.hu','zTaD[fIGpgCI');
  321. foreach ($dom->file as $file) {
  322. ftp_get($ftp,$file['path'],$file['path'],FTP_ASCII);
  323. }
  324. return $dom->message;
  325. }
  326. else {
  327. return '';
  328. }
  329. }
  330. static function getSiteName($default='') {
  331. self::dbconnect();
  332. global $conn;
  333. $res = mysqli_query($conn,"select * from azonics_settings where setting_name='SITENAME' and setting_status='1';");
  334. if (mysqli_num_rows($res)>0) {
  335. $row = mysqli_fetch_array($res);
  336. return $row['setting_value_text'];
  337. }
  338. else {
  339. return $default;
  340. }
  341. }
  342. static function getPageName() {
  343. self::dbconnect();
  344. global $conn;
  345. $res = mysqli_query($conn,"select * from azonics_settings where setting_name='PAGENAME' and setting_status='1';");
  346. if (mysqli_num_rows($res)>0) {
  347. $row = mysqli_fetch_array($res);
  348. return $row['setting_value_text'];
  349. }
  350. else {
  351. return '';
  352. }
  353. }
  354. static function getBaseColorScheme($default='') {
  355. self::dbconnect();
  356. global $conn;
  357. $res = mysqli_query($conn,"select * from azonics_settings where setting_name='COLOR' and setting_status='1';");
  358. if (mysqli_num_rows($res)>0) {
  359. $row = mysqli_fetch_array($res);
  360. return $row['setting_value_text'];
  361. }
  362. else {
  363. return $default;
  364. }
  365. }
  366. static function getSlogan($default='') {
  367. self::dbconnect();
  368. global $conn;
  369. $res = mysqli_query($conn,"select * from azonics_settings where setting_name='SLOGAN' and setting_status='1';");
  370. if (mysqli_num_rows($res)>0) {
  371. $row = mysqli_fetch_array($res);
  372. return $row['setting_value_text'];
  373. }
  374. else {
  375. return $default;
  376. }
  377. }
  378. static function userComboBox($sel='') {
  379. self::dbconnect();
  380. global $conn;
  381. $res = mysqli_query($conn,"select * from azonics_users where user_status<>'0' order by user_nick asc;");
  382. $result = '<option value="">'.lang::_('Choose user').'</option>';
  383. if (mysqli_num_rows($res)>0) {
  384. while ($row = mysqli_fetch_array($res)) {
  385. if ($sel==$row['user_id']) {
  386. $result.= '<option value="'.$row['user_id'].'" selected>'.$row['user_nick'].' ('.$row['user_first_name'].' '.$row['user_last_name'].')</option>';
  387. }
  388. else {
  389. $result.= '<option value="'.$row['user_id'].'">'.$row['user_nick'].' ('.$row['user_first_name'].' '.$row['user_last_name'].')</option>';
  390. }
  391. }
  392. }
  393. return $result;
  394. }
  395. static function getUserNameByID($user_id='') {
  396. self::dbconnect();
  397. global $conn;
  398. $user_id = mysql_real_escape_string($user_id);
  399. $res = mysqli_query($conn,"select * from azonics_users where user_id='".$user_id."';");
  400. if (mysqli_num_rows($res)>0) {
  401. $row = mysqli_fetch_array($res);
  402. return $row['user_first_name'].' '.$row['user_last_name'].' ('.$row['user_nick'].')';
  403. }
  404. else {
  405. return false;
  406. }
  407. }
  408. static function categoryComboBox($sel='') {
  409. self::dbconnect();
  410. global $conn;
  411. $res = mysqli_query($conn,"select * from azonics_categories where category_status<>'0' order by category_name asc;");
  412. $result = '<option value="">'.lang::_('Choose category').'</option>';
  413. if (mysqli_num_rows($res)>0) {
  414. while ($row = mysqli_fetch_array($res)) {
  415. if ($sel==$row['category_id']) {
  416. $result.= '<option value="'.$row['category_id'].'" selected>'.$row['category_name'].'</option>';
  417. }
  418. else {
  419. $result.= '<option value="'.$row['category_id'].'">'.$row['category_name'].'</option>';
  420. }
  421. }
  422. }
  423. return $result;
  424. }
  425. static function getProfileCategory($id='') {
  426. self::dbconnect();
  427. global $conn;
  428. if ($id!='') {
  429. $res = mysqli_query($conn,"select * from azonics_categories where category_id='".$id."';");
  430. $row = mysqli_fetch_array($res);
  431. return $row['category_name'];
  432. }
  433. else {
  434. return false;
  435. }
  436. }
  437. static function getProductStatus($status='',$pid='') {
  438. if ($status=='1') {
  439. return '<div class="btn-group">'
  440. . '<button type="button" class="btn btn-success">'.lang::_('Active').'</button>'
  441. . '<button aria-expanded="false" type="button" class="btn btn-success dropdown-toggle" data-toggle="dropdown">'
  442. . '<span class="caret"></span>'
  443. . '<span class="sr-only">Toggle Dropdown</span>'
  444. . '</button>'
  445. . '<ul class="dropdown-menu" role="menu">'
  446. . '<li><a href="/admin/products/set/?status=3&id='.$pid.'">'.lang::_('Set inactive').'</a></li>'
  447. . '<li><a href="/admin/products/delete/?id='.$pid.'">'.lang::_('Delete').'</a></li>'
  448. . '</ul>'
  449. . '</div>';
  450. }
  451. else if ($status=='3') {
  452. return '<div class="btn-group">'
  453. . '<button type="button" class="btn btn-default">'.lang::_('Inactive').'</button>'
  454. . '<button aria-expanded="false" type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">'
  455. . '<span class="caret"></span>'
  456. . '<span class="sr-only">Toggle Dropdown</span>'
  457. . '</button>'
  458. . '<ul class="dropdown-menu" role="menu">'
  459. . '<li><a href="/admin/products/set/?status=1&id='.$pid.'">'.lang::_('Set active').'</a></li>'
  460. . '<li><a href="/admin/products/delete/?id='.$pid.'">'.lang::_('Delete').'</a></li>'
  461. . '</ul>'
  462. . '</div>';
  463. }
  464. }
  465. static function getProfileStatus($status='',$pid='') {
  466. if ($status=='1') {
  467. return '<div class="btn-group">'
  468. . '<button type="button" class="btn btn-xs btn-success">'.lang::_('Active').'</button>'
  469. . '<button aria-expanded="false" type="button" class="btn btn-success btn-xs dropdown-toggle" data-toggle="dropdown">'
  470. . '<span class="caret"></span>'
  471. . '<span class="sr-only">Toggle Dropdown</span>'
  472. . '</button>'
  473. . '<ul class="dropdown-menu" role="menu">'
  474. . '<li><a href="/admin/profiles/set/?status=2&id='.$pid.'">'.lang::_('Set inactive').'</a></li>'
  475. . '<li><a href="/admin/profiles/delete/?id='.$pid.'">'.lang::_('Delete').'</a></li>'
  476. . '</ul>'
  477. . '</div>';
  478. }
  479. else if ($status=='2') {
  480. return '<div class="btn-group">'
  481. . '<button type="button" class="btn btn-xs btn-default">'.lang::_('Inactive').'</button>'
  482. . '<button aria-expanded="false" type="button" class="btn btn-default btn-xs dropdown-toggle" data-toggle="dropdown">'
  483. . '<span class="caret"></span>'
  484. . '<span class="sr-only">Toggle Dropdown</span>'
  485. . '</button>'
  486. . '<ul class="dropdown-menu" role="menu">'
  487. . '<li><a href="/admin/profiles/set/?status=1&id='.$pid.'">'.lang::_('Set active').'</a></li>'
  488. . '<li><a href="/admin/profiles/delete/?id='.$pid.'">'.lang::_('Delete').'</a></li>'
  489. . '</ul>'
  490. . '</div>';
  491. }
  492. else if ($status=='3') {
  493. return '<div class="btn-group">'
  494. . '<button type="button" class="btn btn-xs btn-info">'.lang::_('Waiting').'</button>'
  495. . '<button aria-expanded="false" type="button" class="btn btn-info btn-xs dropdown-toggle" data-toggle="dropdown">'
  496. . '<span class="caret"></span>'
  497. . '<span class="sr-only">Toggle Dropdown</span>'
  498. . '</button>'
  499. . '<ul class="dropdown-menu" role="menu">'
  500. . '<li><a href="/admin/profiles/set/?status=1&id='.$pid.'">'.lang::_('Enable').'</a></li>'
  501. . '<li><a href="/admin/profiles/delete/?id='.$pid.'">'.lang::_('Delete').'</a></li>'
  502. . '</ul>'
  503. . '</div>';
  504. }
  505. }
  506. static function getMainImage($pid) {
  507. self::dbconnect();
  508. global $conn;
  509. $res2 = mysqli_query($conn,"select * from azonics_galeries where "
  510. . "galery_design_id='".$pid."' and "
  511. . "galery_status='1' and galery_main_image='1';");
  512. if (mysqli_num_rows($res2)>0) {
  513. $row2 = mysqli_fetch_array($res2);
  514. return '<img src="'.BASE_URL.$row2['galery_image'].'" alt="Image" />';
  515. }
  516. else {
  517. return '<img src="http://placehold.it/500x500" alt="Image" />';
  518. }
  519. }
  520. static function battleTypesOptions($sel='') {
  521. self::dbconnect();
  522. global $conn;
  523. $res_bt = mysqli_query($conn,"select * from azonics_battle_types where "
  524. . "battle_type_status='1' "
  525. . "order by battle_type_name asc;");
  526. $temp = '<option value="">Choose battle type</option>';
  527. if (mysqli_num_rows($res_bt)>0) {
  528. while ($row_bt = mysqli_fetch_array($res_bt)) {
  529. if ($sel==$row_bt['battle_type_id']) {
  530. $temp.= '<option value="'.$row_bt['battle_type_id'].'" selected>'.$row_bt['battle_type_name'].'</option>';
  531. }
  532. else {
  533. $temp.= '<option value="'.$row_bt['battle_type_id'].'">'.$row_bt['battle_type_name'].'</option>';
  534. }
  535. }
  536. }
  537. return $temp;
  538. }
  539. static function battleAwardsOptions($sel='') {
  540. self::dbconnect();
  541. global $conn;
  542. $res_bw = mysqli_query($conn,"select * from azonics_awards where "
  543. . "award_status='1' "
  544. . "order by award_name asc;");
  545. $temp = '<option value="">Choose award</option>';
  546. if (mysqli_num_rows($res_bw)>0) {
  547. while ($row_bw = mysqli_fetch_array($res_bw)) {
  548. if ($sel==$row_bw['award_id']) {
  549. $temp.= '<option value="'.$row_bw['award_id'].'" selected>'.$row_bw['award_name'].'</option>';
  550. }
  551. else {
  552. $temp.= '<option value="'.$row_bw['award_id'].'">'.$row_bw['award_name'].'</option>';
  553. }
  554. }
  555. }
  556. return $temp;
  557. }
  558. static function getBattleType($type_id='') {
  559. self::dbconnect();
  560. global $conn;
  561. if ($type_id!='') {
  562. $res_type = mysqli_query($conn,"select * from azonics_battle_types where battle_type_id='".$type_id."';");
  563. if (mysqli_num_rows($res_type)>0) {
  564. $row_type = mysqli_fetch_array($res_type);
  565. return $row_type['battle_type_name'];
  566. }
  567. else {
  568. return false;
  569. }
  570. }
  571. else {
  572. return false;
  573. }
  574. }
  575. static function getBattleAward($award_id='') {
  576. self::dbconnect();
  577. global $conn;
  578. if ($award_id!='') {
  579. $res_award = mysqli_query($conn,"select * from azonics_awards where award_id='".$award_id."';");
  580. if (mysqli_num_rows($res_award)>0) {
  581. $row_award = mysqli_fetch_array($res_award);
  582. return $row_award['award_name'];
  583. }
  584. else {
  585. return false;
  586. }
  587. }
  588. else {
  589. return false;
  590. }
  591. }
  592. static function generateSlug($name='') {
  593. if ($name!='') {
  594. $text = preg_replace('~[^\\pL\d]+~u', '-', $text);
  595. $text = trim($text, '-');
  596. $text = iconv('utf-8', 'us-ascii//TRANSLIT', $text);
  597. $text = strtolower($text);
  598. $text = preg_replace('~[^-\w]+~', '', $text);
  599. if (empty($text)) return time();
  600. return $text;
  601. }
  602. else {
  603. return time();
  604. }
  605. }
  606. static function getProductTags($product_category='') {
  607. $tags = explode(",",$product_category);
  608. foreach ($tags as $tag) {
  609. if ($tag!='') $list.= '<span class="label label-info">'.$tag.'</span>&nbsp;';
  610. }
  611. return $list;
  612. }
  613. static function getProductMeta($product_id='') {
  614. self::dbconnect();
  615. global $conn;
  616. $list = '';
  617. if ($product_id!='') {
  618. $res = mysqli_query($conn,"select * from azonics_product_meta where "
  619. . "meta_pid='".$product_id."' and "
  620. . "meta_status='1' order by meta_date asc;");
  621. if (mysqli_num_rows($res)>0) {
  622. while ($row = mysqli_fetch_array($res)) {
  623. $list.= '<!--Metarow:'.$row['meta_id'].'-->'
  624. . '<tr>'
  625. . '<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>'
  626. . '<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>'
  627. . '<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>'
  628. . '</tr>';
  629. }
  630. }
  631. }
  632. return $list;
  633. }
  634. static function bannerZones($selectedZone='') {
  635. $temp = '<option value="">'.lang::_('Choose banner zone!').'</option>';
  636. if ($selectedZone=='zone1') {
  637. $temp.= '<option value="zone1" selected>'.lang::_('Főoldali slider').'</option>';
  638. }
  639. else {
  640. $temp.= '<option value="zone1">'.lang::_('Főoldali slider').'</option>';
  641. }
  642. return $temp;
  643. }
  644. static function getBannerZoneName($zone_id) {
  645. if ($zone_id=='zone1') {
  646. return lang::_('Speciális kínálat');
  647. }
  648. else {
  649. return lang::_('Rólunk mondták');
  650. }
  651. }
  652. static function trim_url($url) {
  653. if ($url!='') {
  654. $url = str_replace("http://","",$url);
  655. }
  656. return $url;
  657. }
  658. static function add_url_prefix($url) {
  659. if ($url!='') {
  660. $url = "http://".$url;
  661. }
  662. return $url;
  663. }
  664. static function get_category_selector($selected) {
  665. self::dbconnect();
  666. global $conn;
  667. $res = mysqli_query($conn,"select * from azonics_categories where category_status='0' order by category_name asc;");
  668. $options = '';
  669. if (mysqli_num_rows($res)>0) {
  670. while ($row = mysqli_fetch_object($res)) {
  671. if ($_SESSION['category']=='') $_SESSION['category'] = $row->category_id;
  672. if ($selected==$row->category_id) {
  673. $options.= '<option value="'.$row->category_id.'" selected>'.$row->category_name.'</option>';
  674. }
  675. else {
  676. $options.= '<option value="'.$row->category_id.'">'.$row->category_name.'</option>';
  677. }
  678. }
  679. }
  680. if ($_SESSION['category']=='') $_SESSION['category'] = '0';
  681. $options.= '<option value="0">'.lang::_('Minden kategória').'</option>';
  682. return $options;
  683. }
  684. static function getLendingStatusByID($status_id='1',$field='ls_name') {
  685. self::dbconnect();
  686. global $conn;
  687. if ($status_id!='') {
  688. $res_item = mysqli_query($conn,"select * from mingo_lending_status where ls_id='".$status_id."';");
  689. $row_item = mysqli_fetch_array($res_item);
  690. return $row_item[$field];
  691. }
  692. else {
  693. return false;
  694. }
  695. }
  696. static function getLendingStatusCombo($selected='1',$lending_id='') {
  697. self::dbconnect();
  698. global $conn;
  699. $res = mysqli_query($conn,"select * from mingo_lending_status where ls_status='1' order by ls_id asc;");
  700. if ($selected=='') $selected='1';
  701. $result = '<div class="btn-group">';
  702. $result.= '<button type="button" class="btn '.self::getLendingStatusByID($selected,'ls_color').'">'.self::getLendingStatusByID($selected,'ls_name').'</button>';
  703. $result.= '<button aria-expanded="false" type="button" class="btn '.self::getLendingStatusByID($selected,'ls_color').' dropdown-toggle" data-toggle="dropdown">
  704. <span class="caret"></span>
  705. <span class="sr-only">Toggle Dropdown</span>
  706. </button>
  707. <ul class="dropdown-menu" role="menu">';
  708. if (mysqli_num_rows($res)>0) {
  709. while ($row = mysqli_fetch_array($res)) {
  710. $result.= '<li><a href="/admin/lendings/set/?status='.$row['ls_id'].'&lending_id='.$lending_id.'">'.$row['ls_name'].'</a></li>';
  711. }
  712. }
  713. $result.= '</ul></div>';
  714. return $result;
  715. }
  716. static function lendingStatusComboBox($selected='') {
  717. self::dbconnect();
  718. global $conn;
  719. $res = mysqli_query($conn,"select * from mingo_lending_status where ls_status='1' order by ls_id asc;");
  720. if (mysqli_num_rows($res)>0) {
  721. while ($row = mysqli_fetch_array($res)) {
  722. if ($selected==$row['ls_id']) {
  723. $result.= '<option value="'.$row['ls_id'].'" selected>'.$row['ls_name'].'</option>';
  724. }
  725. else {
  726. $result.= '<option value="'.$row['ls_id'].'">'.$row['ls_name'].'</option>';
  727. }
  728. }
  729. }
  730. else {
  731. $result.= '<option value="0">Nem lehet státuszt állítani!</option>';
  732. }
  733. return $result;
  734. }
  735. static function get_todos($show_all='all',$uid=0,$lending_id=0,$limit=10,$orderby='todo_date',$order='asc',$comments=false,$finished=true) {
  736. self::dbconnect();
  737. global $conn;
  738. if ($comments==true) {
  739. $comments_selector = " and todo_date<>'NULL'";
  740. }
  741. else {
  742. $comments_selector = '';
  743. }
  744. if ($finished==false) {
  745. $finish = " and todo_finished<>'1'";
  746. }
  747. else {
  748. $finish = "";
  749. }
  750. if ($show_all=='all') {
  751. $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.";");
  752. }
  753. elseif ($show_all=='users') {
  754. $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.";");
  755. }
  756. elseif ($show_all=='lendings') {
  757. $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.";");
  758. }
  759. elseif ($uid>0) {
  760. $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.";");
  761. }
  762. elseif ($lending_id>0) {
  763. $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.";");
  764. }
  765. if (mysqli_num_rows($res)>0) {
  766. while ($row = mysqli_fetch_object($res)) {
  767. $result[] = $row;
  768. }
  769. return $result;
  770. }
  771. else {
  772. return false;
  773. }
  774. }
  775. function get_todo_object($id) {
  776. self::dbconnect();
  777. global $conn;
  778. $res = mysqli_query($conn,"select * from mingo_todos where todo_id='".$id."';");
  779. if (mysqli_num_rows($res)>0) {
  780. return mysqli_fetch_object($res);
  781. }
  782. else {
  783. return false;
  784. }
  785. }
  786. function get_group_options($group,$selected='') {
  787. self::dbconnect();
  788. global $conn;
  789. $res = mysqli_query($conn,"SELECT * FROM sc_variants WHERE variant_group='".$group."' AND variant_status='1' ORDER BY variant_name ASC;");
  790. $result = '<option value="">Válasszon!</option>';
  791. if (mysqli_num_rows($res)>0) {
  792. while ($row = mysqli_fetch_array($res)) {
  793. if ($selected==$row['variant_id']) {
  794. $result.= '<option value="'.$row['variant_id'].'" selected>'.$row['variant_name'].'</option>';
  795. }
  796. else {
  797. $result.= '<option value="'.$row['variant_id'].'">'.$row['variant_name'].'</option>';
  798. }
  799. }
  800. }
  801. return $result;
  802. }
  803. function get_rajz($cikkszam='') {
  804. self::dbconnect();
  805. global $conn;
  806. if ($cikkszam!='') {
  807. $res = mysqli_query($conn,"select * from sc_rajzok where rajz_cikkszam='".$cikkszam."' and rajz_status='1';");
  808. if (mysqli_num_rows($res)>0) {
  809. $row = mysqli_fetch_array($res);
  810. return $row['rajz_file'];
  811. }
  812. else {
  813. return false;
  814. }
  815. }
  816. else {
  817. return false;
  818. }
  819. }
  820. function has_rajz($cikkszam='') {
  821. self::dbconnect();
  822. global $conn;
  823. if ($cikkszam!='') {
  824. $res = mysqli_query($conn,"select * from sc_rajzok where rajz_cikkszam='".$cikkszam."' and rajz_status='1';");
  825. if (mysqli_num_rows($res)>0) {
  826. return true;
  827. }
  828. else {
  829. return false;
  830. }
  831. }
  832. else {
  833. return false;
  834. }
  835. }
  836. function has_document($id) {
  837. self::dbconnect();
  838. global $conn;
  839. if ($id!='') {
  840. $res = mysqli_query($conn,"select * from sc_beszerzes where beszer_id='".$id."';");
  841. if (mysqli_num_rows($res)>0) {
  842. $row = mysqli_fetch_array($res);
  843. return $row['beszer_document'];
  844. }
  845. else {
  846. return false;
  847. }
  848. }
  849. else {
  850. return false;
  851. }
  852. }
  853. function has_bill_image($bill_number='') {
  854. self::dbconnect();
  855. global $conn;
  856. if ($bill_number!='') {
  857. $res = mysqli_query($conn,"select * from sc_bills where bill_number='".$bill_number."' and bill_status='1';");
  858. if (mysqli_num_rows($res)>0) {
  859. return true;
  860. }
  861. else {
  862. return false;
  863. }
  864. }
  865. else {
  866. return false;
  867. }
  868. }
  869. function get_bill_image($bill_number='') {
  870. self::dbconnect();
  871. global $conn;
  872. if ($bill_number!='') {
  873. $res = mysqli_query($conn,"select * from sc_bills where bill_number='".$bill_number."' and bill_status='1';");
  874. if (mysqli_num_rows($res)>0) {
  875. $row = mysqli_fetch_array($res);
  876. return $row['bill_image'];
  877. }
  878. else {
  879. return false;
  880. }
  881. }
  882. else {
  883. return false;
  884. }
  885. }
  886. function check_admin_access_to_action() {
  887. if ($_SESSION['admin_user']->admin_access_level=='1') {
  888. return true;
  889. }
  890. else {
  891. return false;
  892. }
  893. }
  894. function get_modules_select($selected='') {
  895. self::dbconnect();
  896. global $conn;
  897. $res = mysqli_query($conn,"SELECT * FROM azonics_modules WHERE module_status='1' ORDER BY display_order ASC;");
  898. $result = '';
  899. if (mysqli_num_rows($res)>0) {
  900. while ($row = mysqli_fetch_array($res)) {
  901. if ($selected==$row['module_controller']) {
  902. $result.= '<option value="'.$row['module_controller'].'" selected>'.$row['module_name'].'</option>';
  903. }
  904. else {
  905. $result.= '<option value="'.$row['module_controller'].'">'.$row['module_name'].'</option>';
  906. }
  907. }
  908. }
  909. return $result;
  910. }
  911. static function get_product_data($pid) {
  912. self::dbconnect();
  913. global $conn;
  914. if ($pid!=='') {
  915. $res = mysqli_query($conn,"SELECT * FROM products_temp WHERE id='".$pid."';");
  916. if (mysqli_num_rows($res)>0) {
  917. $row = mysqli_fetch_object($res);
  918. $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;
  919. return $result;
  920. }
  921. else {
  922. return false;
  923. }
  924. }
  925. else {
  926. return false;
  927. }
  928. }
  929. static function get_product_image($pid,$type) {
  930. self::dbconnect();
  931. global $conn;
  932. if ($pid!=='' && $type!=='') {
  933. $res = mysqli_query($conn,"SELECT * FROM products_temp WHERE id='".$pid."';");
  934. if (mysqli_num_rows($res)>0) {
  935. $row = mysqli_fetch_object($res);
  936. if ($row->$type!==NULL) {
  937. $result = '<img src="http://webshop.rackmester.hu/'.$row->$type.'" style="width: 50px;" />';
  938. }
  939. else {
  940. $result = ' - ';
  941. }
  942. return $result;
  943. }
  944. else {
  945. return false;
  946. }
  947. }
  948. else {
  949. return false;
  950. }
  951. }
  952. static function get_ertekkeszlet($kategoria,$mezo) {
  953. self::dbconnect();
  954. global $conn;
  955. if ($kategoria!=='' && $mezo!=='') {
  956. $res = mysqli_query($conn,"SELECT * FROM azonics_codomains WHERE kategoria='".$kategoria."' AND mezo='".$mezo."' AND status='1' ORDER BY ertek ASC;");
  957. if (mysqli_num_rows($res)>0) {
  958. while ($row = mysqli_fetch_array($res)) {
  959. $result[] = $row['ertek'];
  960. }
  961. return $result;
  962. }
  963. else {
  964. return false;
  965. }
  966. }
  967. else {
  968. return false;
  969. }
  970. }
  971. static function get_category_factor($category) {
  972. self::dbconnect();
  973. global $conn;
  974. if ($category!='') {
  975. $res = mysqli_query($conn,"SELECT * FROM azonics_category_price_factors WHERE category='".$category."' AND status='1';");
  976. if (mysqli_num_rows($res)>0) {
  977. return mysqli_fetch_object($res);
  978. }
  979. else {
  980. return false;
  981. }
  982. }
  983. else {
  984. return false;
  985. }
  986. }
  987. static function get_velemenyek_by_agent_id($agentid) {
  988. self::dbconnect();
  989. global $conn;
  990. if ($agentid!='') {
  991. $res = mysqli_query($conn,"SELECT * FROM velemenyek WHERE agent_id='".$agentid."';");
  992. return mysqli_num_rows($res);
  993. }
  994. else {
  995. return 0;
  996. }
  997. }
  998. }