' => FILTER_SANITIZE_STRING, 'view_res_att' => FILTER_SANITIZE_STRING); $urlpath = filter_input_array(INPUT_GET, $urlarguments); $urlpath['error_mes'] = urldecode($urlpath['error_mes']); /** * authorization (status of authorization & info about user) */ //check authorization $authorization = array( 'auth' => false, 'status' => 'guest', 'url_param' => false); if(isset($_SESSION['admin']) && isset($_SESSION['password']) && isset($_SESSION['admin_is_here'])) { $auth = true; $status = 'admin'; //control panel status if($_SESSION['usr_arr']['admin_panel'] == 1) { $admin_panel = true; } else { $admin_panel = false; } } elseif(isset($_SESSION['user']) && isset($_SESSION['password']) && !isset($noauth)) { $auth = true; $status = 'user'; $noauth_url_param = false; } else { $auth = false; $status = 'guest'; $noauth_url_param = '&noauth=1'; } $authorization['auth'] = $auth; $authorization['status'] = $status; $authorization['url_param'] = $noauth_url_param; unset($auth, $status, $noauth_url_param); /** *current RAZDEL */ if(!empty($urlpath['razdel'])) { $search_r = mysql_real_escape_string($urlpath['razdel']); $chk_existance = mysql_query("SELECT `id`, `hidden` FROM `razdeli` WHERE `name` = '".$search_r."' LIMIT 1"); if(!mysql_num_rows($chk_existance)) {//if razdel not exists $page404 = true; } else { $hChk = mysql_fetch_row($chk_existance); if($hChk[1] == 1) { //if razdel is hidden $page404 = true; } else { $razdel = $urlpath['razdel']; } } } else { $first_razdel = mysql_query("SELECT `name` FROM `razdeli` WHERE `parent` = 'root' AND `order` <> '0' ORDER BY `order` LIMIT 1"); $row = mysql_fetch_row($first_razdel); $urlpath['razdel'] = $row[0]; $razdel = $row[0]; } /* *Main Menu */ $sel_topm = mysql_query("SELECT `id`, `name`, `real_name`, `access`, `default_content`, `navigation_mode`, `allow_mode_change` FROM `razdeli` WHERE `parent` = 'root' AND `hidden` = '0' ORDER BY `order`") or die(mysql_error()); if(mysql_num_rows($sel_topm)) { $main_menu_btn = array(); //array with main menu buttons params while($topm_array = mysql_fetch_assoc($sel_topm)) { $topm_name = $topm_array['name']; $topm_rname = $topm_array['real_name']; $topm_access = $topm_array['access']; $topbutton_access = checkAccessRights($topm_access); if($topbutton_access[0] == false or ($topbutton_access[0] == true && $topbutton_access[1] == true)) { if ($topm_name == $razdel) { $tb_style = 'topmenu_abutton'; //navigation mode of the active razdel if(!empty($urlpath['subrazdel']) or !empty($urlpath['itm'])) { $navigation_mode = 1; $allow_mode_change = 0; } else { $navigation_mode = $topm_array['navigation_mode']; $allow_mode_change = $topm_array['allow_mode_change']; } $razdel_id = $topm_array['id']; $razdel_name = $topm_array['real_name']; $default_content = $topm_array['default_content']; //default content for this razdel (to include in moduls array) } else { $tb_style = 'topmenu_button'; } //setting params into the array $main_menu_btn[] = array('id' => $topm_array['id'], 'razdel' => $topm_name, 'text' => $topm_rname, 'access' => $topm_access, 'css_class' => $tb_style); } } unset($topm_name, $topm_rname, $topm_access, $topbutton_access, $tb_style); //cleaning vars from last iteration } /** *Secondary Menu */ if(!isset($page404) && $razdel != 'lc') { //if page is correct and if is alowed to create subrazdels (razdel is not user's profile) //Level 1 (subrazdels) $sel_sidem = mysql_query("SELECT `id`, `parent`, `name`, `real_name`, `type`, `access` FROM `razdeli` WHERE `parent` = '".$razdel."' AND `hidden` = '0' ORDER BY `order`"); if(mysql_num_rows($sel_sidem)) { $second_menu_btn = array(); //array with secondary menu buttons params while($sidem_array = mysql_fetch_assoc($sel_sidem)) { $sidem_id = $sidem_array['id']; $sidem_parent = $sidem_array['parent']; $sidem_name = $sidem_array['name']; $sidem_rname = $sidem_array['HERE `parent` = '".$sidem_name."' AND `hidden` = '0' ORDER BY `order`") or die(mysql_error()); if(mysql_num_rows($sel_subpunkts)) { $subpunkts_btn = array(); //array with submenu buttons params while($subpunkt_array = mysql_fetch_assoc($sel_subpunkts)) { $subpunkt_id = $subpunkt_array['id']; $subpunkt_parent = $subpunkt_array['parent']; $subpunkt_name = $subpunkt_array['name']; $subpunkt_rname = $subpunkt_array['real_name']; $subpunkt_type = $subpunkt_array['type']; $subpunkt_access = $subpunkt_array['access']; //subcategory name for navigation array if($subpunkt_name == $urlpath['subcat']) { $subcat_name = $subpunkt_array['real_name']; } $subbutton_access = checkAccessRights($subpunkt_access); //rendering subpunkt buttons if($subbutton_access[0] == false or ($subbutton_access[0] == true && $subbutton_access[1] == true)) { $subpunkts_btn[] = array('id' => $subpunkt_id, 'parent' => $sidem_name, 'link' => $subpunkt_name, 'text' => $subpunkt_rname, 'type' => $subpunkt_type, 'access' => $subpunkt_access); } } unset($subpunkt_id, $subpunkt_parent, $subpunkt_name, $subpunkt_rname, $subpunkt_type, $subpunkt_access, $subbutton_access); } else { $subpunkts_btn = false; //array with secondary menu buttons params } } else { $subpunkts_btn = false; } //setting params into the array $second_menu_btn[] = array('id' => $sidem_id, 'parent' => $sidem_parent, 'name' => $sidem_name, 'linkgo' => $sidem_link, 'linkscroll' => $link_scroll, 'text' => $sidem_rname, 'type' => $sidem_type, 'access' => $sidem_access, 'css_class' => $sb_style, 'submenu' => $subpunkts_btn); } } unset($sidem_id, $sidem_parent, $sidem_name, $sidem_rname, $sidem_type, $sidem_access, $sb_style); //cleaning vars from last iteration } } /** *array with navigation and structure params * * parent - name (latin) of current razdel (the same as 'razdel'). Used to be supplied as a parameter to call admin forms */ //define links for subrazdels & categories to use in navigation links if($urlpath['subcat']) { //if we're inside a category $subrazdel_link = '&subrazdel='.$urlpath['subrazdel']; $subcat_link = '&subcat='.$urlpath['subcat']; $link_tail = $subrazdel_link.$subcat_link; } else { $subrazdel_link = false; $subcat_link = false; $link_tail = '&subrazdel='.$urlpath['subrazdel']; } $navigation = array('id' => $razdel_id, 'razdel' => $razdel, 'parent' => $razdel, 'real_name' => $razdel_name, 'razdel_name' => $razdel_name, 'main_menu' => $main_menu_btn, 'navmode' => $navigation_mode, 'navmode_change' => $allow_mode_change, 'page404' => $page404, 'subrazdel' => $urlpath['subrazdel'], 'subrazdel_name' => $subrazdel_name, 'second_menu' => $second_menu_btn, 'subcat' => $urlpath['subcat'], 'subcat_name' => $subcat_name, 'subrazdel_link' => $subrazdel_link, 'subcat_link' => $subcat_link, 'link_tail' => $link_tail); unset($razdel, $razdel_name, $main_menu_btn, $navigation_mode, $allow_mode_change, $page404, $subrazdel_name, $subrazdel, $subcat_name, $second_menu_btn, $subrazdel_link, $subcat_link, $link_tail); /** *END OF NAVIGATION & STRUCTURE */ /** *BLOCKS (VIDGETS etc.) */ $blocks = array(); $get_vidgets = mysql_query("SELECT * FROM `vidgets` WHERE `hidden` <> '1' ORDER BY `order`"); if(mysql_num_rows($get_vidgets)) { while($blocks_arr = mysql_fetch_assoc($get_vidgets)) { //get vidgets data switch($blocks_arr['type']) { case 'banners': $sql = "SELECT `rname`, `order`, `image`, `link`, `code` FROM `banners` WHERE `vidget_id` = '".$blocks_arr['id']."' AND `hidden` <> 1 ORDER BY `order`"; break; case 'freepage': $sql = "SELECT `title`, `content` FROM `freepage` WHERE `vidget_id` = '".$blocks_arr['id']."' LIMIT 1"; break; case 'great_thoughts': //row amount $gs_rows = mysql_query("select SQL_CALC_FOUND_ROWS * FROM `great_thoughts`"); $gs_total = mysql_num_rows($gs_rows); $r_id = rand(1, $gs_total); $sql = "SELECT `author`, `text` FROM `great_thoughts` WHERE `id` = '".$r_id."' LIMIT 1"; unset($gs_rows, $gs_total, $r_id); break; case 'cert': if(file_exists("grafika".DIRECTORY_SEPARATOR."thumb_certificate.jpg")) { $block_data = true; } else { $block_data = false; } break; case 'lastonforum': //query to select last messages from forum messages table $sql = "SELECT `id`, `forum_id`, `forumcategory_id`, `topic_id`, DATE_FORMAT(`date`, '%d.%m.%Y, %T') as `date`, `content` FROM `forum_messages` ORDER BY `id` DESC LIMIT 10"; //get last forum messages $get_data = mysql_query($sql); if(mysql_num_rows($get_data)) { while($row = mysql_fetch_assoc($get_data)) { //query to select forum information $sql = "SELECT `parent`, `name` FROM `razdeli` WHERE `id` IN (SELECT `subrazdel_id` FROM `forum_blocks` WHERE `id` IN (SELECT `content_id` FROM `forums` WHERE `id` = '".$row['forum_id']."') ) LIMIT 1"; //get forum information $get_forum = mysql_query($sql); if(mysql_num_rows($get_forum)) { $forum_row = mysql_fetch_assoc($get_forum); } //query to get topic name $sql = "SELECT `real_name` FROM `forum_topics` WHERE `id` = '".$row['topic_id']."' LIMIT 1"; //get topis name $get_topic = mysql_query($sql); if(mysql_num_rows($get_topic)) { $topic_row = mysql_fetch_assoc($get_topic); } $block_data[] = array('razdel' => $forum_row['parent'], 'subrazdel' => $forum_row['name'], 'category_id' => $row['forumcategory_id'], 'topic_id' => $row['topic_id'], 'message_id' => $row['id'], 'topic_name' => $topic_row['real_name'], 'message_content' => $row['content'], 'message_date' => $row['date']); } } else { $block_data = false; } unset($mess_limit, $topic_row, $forum_row); break; case 'now_online': if(session_id() == '') { session_start(); } $sess_id = session_id(); if($sess_id != "") { //current time $CurrentTime = time(); //session lifetime $LastTime = time() - 600; //file to store session IDies and time $base = "vidgets".DIRECTORY_SEPARATOR."session.txt"; $file = file($base); $k = 0; for ($i = 0; $i < sizeof($file); $i++) { $line = explode("|", $file[$i]); if ($line[1] > $LastTime) { $ResFile[$k] = $file[$i]; $k++; } } for ($i = 0; $i $blocks_arr['id'], 'order' => $blocks_arr['order'], 'type' => $blocks_arr['type'], 'data' => $block_data); unset($sql, $block_data, $get_data, $row); } } /** * MODULS */ $moduls = array(); $moduls['default_content'] = $default_content; //getting current moduls set (only structure without content) if(!empty($navigation['second_menu'])) { foreach($navigation['second_menu'] as $k => $v) { //if we're inside a subrazdel (but not inside a subcategory) if(!empty($urlpath['subrazdel']) && !$urlpath['subcat']) { if($navigation['second_menu'][$k]['name'] == $urlpath['subrazdel']) { $moduls_set[] = array('id' => $navigation['second_menu'][$k]['id'], 'subrazdel_id' => $navigation['second_menu'][$k]['id'], 'parent' => $navigation['second_menu'][$k]['parent'], 'name' => $navigation['second_menu'][$k]['name'], 'real_name' => $navigation['second_menu'][$k]['text'], 'access' => $navigation['second_menu'][$k]['access'], 'type' => $navigation['second_menu'][$k]['type']); } } elseif(!empty($urlpath['subcat'])) {// if we're inside a subcategory if($navigation['second_menu'][$k]['name'] == $urlpath['subrazdel']) { foreach($navigation['second_menu'][$k]['submenu'] as $sub_k => $sub_v) { if($navigation['second_menu'][$k]['submenu'][$sub_k]['link'] == $urlpath['subcat']) { $moduls_set[] = array('id' => $navigation['second_menu'][$k]['submenu'][$sub_k]['id'], 'subrazdel_id' => $navigation['second_menu'][$k]['submenu'][$sub_k]['id'], 'parent' => $navigation['second_menu'][$k]['submenu'][$sub_k]['parent'], 'name' => $navigation['second_menu'][$k]['submenu'][$sub_k]['link'], 'real_name' => $navigation['second_menu'][$k]['submenu'][$sub_k]['text'], 'access' => $navigation['second_menu'][$k]['submenu'][$sub_k]['access'], 'type' => $navigation['second_menu'][$k]['submenu'][$sub_k]['type']); } } } } else { //if we are in the root of current razdel if($navigation['second_menu'][$k]['type'] != 'category') { $moduls_set[] = array('id' => $navigation['second_menu'][$k]['id'], 'subrazdel_id' => $navigation['second_menu'][$k]['id'], 'parent' => $navigation['second_menu'][$k]['parent'], 'name' => $navigation['second_menu'][$k]['name'], 'real_name' => $navigation['second_menu'][$k]['text'], 'access' => $navigation['second_menu'][$k]['access'], 'type' => $navigation['second_menu'][$k]['type']); } } } } //getting content for each module if(is_array($moduls_set)) { $module_access = checkAccessRights($moduls_set['access']); if($module_access[0] == false or ($module_access[0] == true && $module_access[1] == true)) { foreach($moduls_set as $k => $v) { switch($moduls_set[$k]['type']) { /*portfolio moduls*/ case 'visitka': $sql = "SELECT * FROM `personal_data` WHERE `subrazdel_id` = '".$moduls_set[$k]['id']."' LIMIT 1"; break; case 'education': $sql = "SELECT * FRs` WHERE `id` = '".$urlpath['itm']."' LIMIT 1"; $appendix_params = array('module_type' => $moduls_set[$k]['type'], 'appendix_types' => array('poll', 'slideshow', 'documents', 'files', 'fon_music')); $comments_params = array('article_id' => $urlpath['itm'], 'subrazdel_id' => $moduls_set[$k]['id'], 'parent_id' => 0); } else { //calendar block with month grids //block $sql = "SELECT `id`, `name`, `real_name`, `description` FROM `calendar_blocks` WHERE `subrazdel_id` = '".$moduls_set[$k]['id']."' LIMIT 1"; $get_block = mysql_query($sql); if(mysql_num_rows($get_block)) { $block = mysql_fetch_assoc($get_block); //months $sql = "SELECT `id`, `month_index`, `year`, `show_month_title`, `title`, `description`, DATE_FORMAT(`created`, '%d.%m.%Y') as `created` FROM `calendar_months` WHERE `content_id` = '".$block['id']."' ORDER BY `order`"; $get_months = mysql_query($sql); if(mysql_num_rows($get_months)) FROM `calendar_events` WHERE `month_id` = '".$mon_row['id']."' AND `calendar_date` = '".$list_day."' ORDER BY `order`"; $get_events = mysql_query($sql); if(mysql_num_rows($get_events)) { while($row = mysql_fetch_assoc($get_events)) { //appendix /*$appendix = new appendix($row['id'], 'calendar'); $row['appendix'] = $appendix->pack(['poll', 'slideshow', 'documents', 'files', 'fon_music']); unset($appendix);*/ $events[$list_day][] = $row; } } else { $events[$list_day] = false; } } //variables to buield month greed) $running_day = date('w',mktime(0,0,0,$mon_row['month_index'],1,$mon_row['year'])); if ($running_day == 0) { $running_day = $running_day + 6; } else { $running_day = $running_day - 1; } $days_in_month = date('t',mktime(0,0,0,$mon_row['month_index'],1,$mon_row['year'])); //array with information about months (including events) $months[] = array('id' => $mon_row['id'], 'month_index' => $mon_row['month_index'], 'month_name' => $month_name, 'year' => $mon_row['year'], 'running_day' => $running_day, 'days_in_month' => $days_in_month, 'show_month_title' => $mon_row['show_month_title'], 'title' => $mon_row['title'], 'description' => $mon_row['description'], 'created' => $mon_row['created'], 'events' => $events); unset($mon_row, $month_name, $running_day, $days_in_month, $events); } } else { $months = false; } } else { $block = false; } $module_data = $block; if(!empty($months)) { $module_data['months'] = $months; } unset($block, $months); } break; case 'common_content': $sql = "SELECT * FROM `".$moduls_set[$k]['type']."` WHERE `subrazdel_id` = '".$moduls_set[$k]['id']."' LIMIT 1"; $appendix_params = array('module_type' => $moduls_set[$k]['type'], 'appendix_types' => array('poll', 'slideshow', 'documents', 'files')); if(!empty($urlpath['subrazdel'])) { $comments_params = array('article_id' => $urlpath['itm'], 'subrazdel_id' => $moduls_set[$k]['id'], 'parent_id' => 0); } else { } break; case 'fonoteka': //block $sql = "SELECT `id`, `name`, `real_name`, `description`, DATE_FORMAT(`created`, '%d.%m.%Y, %T') as `created` FROM `fonoteka` WHERE `subrazdel_id` = '".$moduls_set[$k]['id']."' LIMIT 1"; $get_block = mysql_query($sql); if(mysql_num_rows($get_block)) { $block = mysql_fetch_assoc($get_block); //sounds $sql = "SELECT `id`, `filename`, `name`, `description`, DATE_FORMAT(`loaded`, '%d.%m.%Y, %T') as `loaded` FROM `fonoteka_files` WHERE `content_id` = '".$block['id']."' ORDER BY `order`"; $get_snd = mysql_query($sql); if(mysql_num_rows($get_snd)) { while($row = mysql_fetch_assoc($get_snd)) { $sounds[] = $row; } } else { $sounds = false; } } else { $block = false; } $module_data = $block; if(!empty($sounds)) { $module_data['sounds'] = $sounds; } unset($block, $sounds); break; case 'fotogallery': if(!empty($urlpath['itm'])) { // block $sql = "SELECT * FROM `fotogallery_albums` WHERE `id` = '".$urlpath['itm']."' LIMIT 1"; $get_block = mysql_query($sql); if(mysql_num_rows($get_block)) { $block = mysql_fetch_assoc($get_block); // fotoes $fotoes_sql = "SELECT `id`, `album`, `filename`, `name`, `description`, DATE_FORMAT(`loaded`, '%d.%m.%Y, %T') as `loaded` FROM `fotogallery` WHERE `album` = '".$block['id']."' ORDER BY `order`"; $get_fotoes = mysql_query($fotoes_sql); if(mysql_num_rows($get_fotoes)) { while($foto_row = mysql_fetch_assoc($get_fotoes)) { $block['fotoes'][] = $foto_row; } } else { $block['fotoes'] = false; } } else { $block = false; } } else { $albums_sql = "SELECT `id`, `name`, `real_name`, `description`, `front_image`, DATE_FORMAT(`created`, '%d.%m.%Y, %T') as `created` FROM `fotogallery_albums` WHERE `subrazdel_id` = '".$moduls_set[$k]['id']."' ORDER BY `order`"; $get_albums = mysql_query($albums_sql); if(mysql_num_rows($get_albums)) { while($album_row = mysql_fetch_assoc($get_albums)) { // fotoes $fotoes_sql = "SELECT `filename`, `front` FROM `fotogallery` WHERE `album` = '".$album_row['id']."' ORDER by `order`"; $get_fotoes = mysql_query($fotoes_sql); if(mysql_num_rows($get_fotoes)) { while($foto_row = mysql_fetch_assoc($get_fotoes)) { $album_row['fotoes'][] = $foto_row; } /* front foto */ // default - 1st foto in array $album_row['front_foto'] = $album_row['fotoes'][0]['filename']; $album_row['fotoes'][0]['skip_on_preview'] = 1; // user defined (if exists - rewrite defaul value) foreach($album_row['fotoes'] as $f_key => $f_val) { if($album_row['fotoes'][$f_key]['front'] == 1) { $album_row['front_foto'] = $album_row['fotoes'][$f_key]['filename']; $album_row['fotoes'][0]['skip_on_preview'] = false; $album_row['fotoes'][$f_key]['skip_on_preview'] = 1; } } } else { $album_row['fotoes'] = false; } $block[] = $album_row; } } else { $block = false; } } $module_data = $block; unset($block); break; case 'gramota': //block $sql = "SELECT `id`, `name`, `real_name`, `description` FROM `gramota_blocks` WHERE `subrazdel_id` = '".$moduls_set[$k]['id']."' LIMIT 1"; $get_block = mysql_query($sql); if(mysql_num_rows($get_block)) { $block = mysql_fetch_assoc($get_block); //events $sql = "SELECT `id`, `content_id`, `title`, `subtitle`, `main_img`, `description`, `show_fullview`, DATE_FORMAT(`created`, '%d.%m.%Y') as `created`, `allow_comments`, `commented`, `keywords` FROM `gramota_events` WHERE `content_id` = '".$block['id']."' ORDER BY `order`"; $get_events = mysql_query($sql); if(mysql_num_rows($get_events)) { $events = array(); while($evnt_row = mysql_fetch_assoc($get_events)) { //documents (gramotas) $sql = "SELECT `id`, `block_id`, `type`, `title_type`, `title_txt`, `title_offset_top`, `title_fontfamily`, `title_fontsize`, `title_fontcolor`, `txt_prefix`, `prefix_offset_top`, `prefix_fontfamily`, `prefix_fontsize`, `prefix_fontcolor`, `subject`, `subj_offset_left`, `subj_offset_top`, `subj_fontfamily`, `subj_fontsize`, `subj_fontcolor`, `main_txt`, `maintxt_offset_top`, `maintxt_fontfamily`, `maintxt_fontsize`, `maintxt_fontcolor`, `signature`, `sign_offset_top`, `sign_fontfamily`, `sign_fontsize`, `sign_fontcolor`, `footer_txt`, `footer_offset_top`, `footer_fontfamily`, `footer_fontsize`, `footer_fontcolor`, `bcgr_id`, `bcgr_filename`, `gramota_filename` FROM `gramotas` WHERE `event_id` = '".$evnt_row['id']."' ORDER BY `order`"; $get_docs = mysql_query($sql); if(mysql_num_rows($get_docs)) { $docs = array(); while($row = mysql_fetch_assoc($get_docs)) { $docs[] = $row; } } else { $docs = false; } $events[] = array('id' => $evnt_row['id'], 'content_id' => $evnt_row['content_id'], 'title' => $evnt_row['title'], 'subtitle' => $evnt_row['subtitle'], 'main_img' => $evnt_row['main_img'], 'description' => $evnt_row['description'], 'show_fullview' => $evnt_row['show_fullview'], 'created' => $evnt_row['created'], 'allow_comments' => $evnt_row['allow_comments'], 'commented' => $evnt_row['commented'], 'keywords' => $evnt_row['keywords'], 'docs' => $docs); } } else { $events = false; } } else { $block = false; } $module_data = $block; unset($block); if(!empty($events)) { $module_data['events'] = $events; unset($events); } break; case 'greeting': $sql = "SELECT * FROM `greeting` WHERE `subrazdel_id` = '".$moduls_set[$k]['id']."' LIMIT 1"; break; case 'guestbook': //block $sql = "SELECT `id`, `subrazdel_id`, `name`, `real_name`, `description`, `users_only` FROM `guestbooks` WHERE `subrazdel_id` = '".$moduls_set[$k]['id']."' LIMIT 1"; $get_block = mysql_query($sql); if(mysql_num_rows($get_block)) { $block = mysql_fetch_assoc($get_block); //messages $sql = "SELECT `id`, `nick`, `user_id`, `name`, `surname`, DATE_FORMAT(`date`, '%d.%m.%Y, %T') as `date`, `content`, DATE_FORMAT(`mod_date`, '%d.%m.%Y') as `mod_date`, `moderator`, `mod_content` FROM `guestbook` WHERE `content_id` = '".$block['id']."' ORDER BY `id` DESC"; $get_mes = mysql_query($sql); if(mysql_num_rows($get_mes)) { while($row = mysql_fetch_assoc($get_mes)) { //user avatar if(file_exists('grafika'.DIRECTORY_SEPARATOR.'razdeli'.DIRECTORY_SEPARATOR.'lc'.DIRECTORY_SEPARATOR.$row['user_id'].'_avatar.jpg')) { $user_ava = 'grafika'.DIRECTORY_SEPARATOR.'razdeli'.DIRECTORY_SEPARATOR.'lc'.DIRECTORY_SEPARATOR.$row['user_id'].'_avatar.jpg'; } else { $user_ava = 'grafika'.DIRECTORY_SEPARATOR.'razdeli'.DIRECTORY_SEPARATOR.'lc'.DIRECTORY_SEPARATOR.'no_avatar.jpg'; } $row['avatar'] = $user_ava; unset($user_ava); //user info (for registered users) if(!empty($row['user_id'])) { $user_info = userInfo('', $row['user_id']); $row['name'] = $user_info['name']; $row['surname'] = $user_info['surname']; unset($user_info); } //moderator info (if a massege had beeen moderated) if(!empty($row['moderator'])) { $user_info = userInfo($row['moderator']); if(!empty($user_info['name']) or !empty($user_info['surname'])) { $row['moderator'] = trim($user_info['name'].' '.$user_info['surname']); } unset($user_info); } $messages[] = $row; } } else { $messages = false; } } else { $block = false; } $module_data = $block; if(!empty($messages)) { $module_data['message $appendix_params = array('module_type' => $moduls_set[$k]['type'], 'appendix_types' => array('poll', 'slideshow', 'documents', 'files', 'fon_music')); $comments_params = array('article_id' => $urlpath['itm'], 'subrazdel_id' => $moduls_set[$k]['id'], 'parent_id' => 0); } else { // get data to check the existance of db entries $sql = "SELECT `id` FROM `news` WHERE `subrazdel_id` = '".$moduls_set[$k]['id']."' LIMIT 1"; #$global_vars['pagination_limit'] = 3; #$sql = "SELECT `id`, `subrazdel_id`, `razdel`, DATE_FORMAT(`date`, '%d.%m.%Y') as `date`, `title`, `main_img`, `short_text`, `full_text`, `published`, `author`, `reads_amount`, `allow_comments`, `commented`, `fon_music` FROM `news` WHERE `subrazdel_id` = '".$moduls_set[$k]['id']."' ORDER BY `id` DESC LIMIT ".$global_vars['pagination_limit'].""; #$comments_params = array('subrazdel_id' => $moduls_set[$k]['id'], 'amount_only' => true); //comment (amount only) #$pagination_params = pagination_params(db_param('news', 'subrazdel_id', $moduls_set[$k]['id']), $global_vars['pagination_limit']); #$sql = false; } break; case 'pics_presentation': //block $sql = "SELECT `id`, `name`, `real_name`, `description`, DATE_FORMAT(`created`, '%d.%m.%Y, %T') as `created`, `onclick` FROM `presentation` WHERE `subrazdel_id` = '".$moduls_set[$k]['id']."' LIMIT 1"; $get_block = mysql_query($sql); if(mysql_num_rows($get_block)) { $block = mysql_fetch_assoc($get_block); //images $sql = "SELECT `id`, `filename`, `name`, `description`, DATE_FORMAT(`loaded`, '%d.%m.%Y, %T') as `loaded` FROM `pics_presentation` WHERE `content_id` = '".$block['id']."' ORDER BY `order`"; $get_pics = mysql_query($sql); if(mysql_num_rows($get_pics)) { while($row = mysql_fetch_assoc($get_pics)) { $row['subrazdel_id'] = $block['id']; $pics[] = $row; } } else { $pics = false; } } else { $block = false; } $module_data = $block; if(!empty($pics)) { $module_data['pics'] = $pics; } unset($block, $pics); break; case 'slider': //block $sql = "SELECT `id`, `name`, `real_name`, `description`, DATE_FORMAT(`created`, '%d.%m.%Y, %T') as `created`, `mode`, `autoplay`, `pause`, `showcontrols`, `shownavigation`, `slide_frame` FROM `slider` WHERE `subrazdel_id` = '".$moduls_set[$k]['id']."' LIMIT 1"; $get_block = mysql_query($sql); if(mysql_num_rows($get_block)) { $block = mysql_fetch_assoc($get_block); //slides $sql = "SELECT `id`, `caption`, `main_img`, `content` FROM `slider_slides` WHERE `content_id` = '".$block['id']."' ORDER BY `order`"; $get_slides = mysql_query($sql); if(mysql_num_rows($get_slides)) { if($block['shownavigation'] == 1) { $slider_navigation =ata['slides'] = $slides; unset($slides); } unset($block); break; case 'anketa': //block $sql = "SELECT `id`, `name`, `real_name`, `description` FROM `anketa_blocks` WHERE `subrazdel_id` = '".$moduls_set[$k]['id']."' LIMIT 1"; $get_block = mysql_query($sql); if(mysql_num_rows($get_block)) { $block = mysql_fetch_assoc($get_block); if($urlpath['itm']) { // single anketa // anketa $anketa_sql = "SELECT `id`, `type`, `real_name`, `description`, `users_only`, `is_published` FROM `ankets` WHERE `id` = '".$urlpath['itm']."' LIMIT 1"; $get_anketa = mysql_query($anketa_sql); if(mysql_num_rows($get_anketa)) { $anketa = mysql_fetch_assoc($get_anketa); // timer amount /* if($anketa['timer'] == 1 && empty($_SESSION['vew_test'])) { $time_sql = "SELECT `start_time` FROM `tests_attempts` WHERE `id` = '".$_SESSION['attempt_id']."' LIMIT 1"; $get_time = mysql_query($time_sql); $time_row = mysql_fetch_row($get_time); $start_time = $time_row[0]; $now = date('Y-m-d H:i:s'); $time_delta = strtotime(date('Y-m-d H:i:s')) - strtotime($start_time); $anketa['timer_val'] = $anketa['timer_amount'] - $time_delta; } */ // anketa questions $questions_sql = "SELECT `id`, `type`, `question_title`, `question_body`, `var1`, `var2`, `var3`, `var4`, `var5`, `var6`, `var7`, `var8`, `var9`, `var10`, `add_img`, `answear` FROM `anketa_questions` WHERE `anketa_id` = '".$anketa['id']."' ORDER BY `order`"; $get_questions = mysql_query($questions_sql) or die(mysql_error()); if($question_amount = mysql_num_rows($get_questions)) { while($question_row = mysql_fetch_assoc($get_questions)) { // unserializing answear string if needed (depends on question type) switch($question_row['type']) { case 'chain': case 'sort': $question_row['answear'] = unserialize($question_row['answear']); if($question_row['type'] == 'chain') { //mixing variants (if "chain" type question) shuffle($question_row['answear']); } if($question_row['type'] == 'sort') { //serializing groups to use as a velue in a form-field $question_row['answear']['group_serialized'] = serialize($question_row['answear']['group']); // gathering all items (variants) and fake items in one array $all_items = array(); foreach($question_row['answear']['values'] as $key => $value) { foreach($question_row['answear']['values'][$key] as $item) { $all_items[] = $item; } } $question_row['answear']['all_items'] = array_merge($all_items, $."'"; $get_user_results = mysql_query($sql_user_results); while($user_result_row = mysql_fetch_assoc($get_user_results)) { $answ = render_answear($user_result_row['question_type'], $user_result_row['user_answear']); $user_result_row['otvet_prefix'] = $answ['text']; $user_result_row['user_answear'] = $answ['answear']; $attempt_row['attempt_user_results'][] = $user_result_row; unset($user_result_row); } $attempts[] = $attempt_row; unset($right_amount, $attempt_row); } } else { // if no attempts $attempts = false; } } // full anketa statistics if($authorization['status'] == 'admin') { $sql_fullstat = "SELECT `id`, `attempt_number`, `user_id`, `name`, `surname`, `email`, `finish_time` FROM `anketa_attempts` WHERE `anketa_id` = '".$anketa['id']."' ORDER BY `id` DESC"; $get_fullstat = mysql_query($sql_fullstat); if(mysql_num_rows($get_fullstat)) { while($fullstat_row = mysql_fetch_assoc($get_fullstat)) { // info about regitered user if($fullstat_row['user_id']) { $fullstat_row['user_status'] = 'registred'; $user = userInfo('', $fullstat_row['user_id']); $fullstat_row['name'] = $user['name']; $fullstat_row['lastname'] = $user['lastname']; $fullstat_row['surname'] = $user['surname']; $fullstat_row['email'] = $user['email']; // info about anonimoys user } else { $fullstat_row['user_status'] = 'guest'; } // date format to use for filter $fullstat_row['date2row'] = date('Y-m-d', strtotime($fullstat_row['finish_time'])); $fullstat[] = $fullstat_row; } } else { // if there are no rows (statistic) $fullstat = false; } } // results for just passed anketa if($urlpath['view_res_att'] && empty($urlpath['error_mes'])) { $attempt_sql = "SELECT `id`, `question_id`, `question_type`, `user_answear` FROM `anketa_results` WHERE `attempt_id` = '".$urlpath['view_res_att']."'"; $get_attempt = mysql_query($attempt_sql); if(mysql_num_rows($get_attempt)) { $last_attempt = array(); while($result_row = mysql_fetch_assoc($get_attempt)) { $answ = render_answear($result_row['question_type'], $result_row['user_answear']); $result_row['text_prefix'] = $answ['text']; $result_row['user_answear'] = $answ['answear']; $last_attempt['questions'][] = $result_row; } } else { $last_attempt = false; } } } else { // if test doesn't esxist $anketa = false; } } else { // all the ankets list $sql = "SELECT `id`, `type`, `name`, `main_img`, `real_name`, `description`, `users_only`, `is_published`, DATE_FORMAT(`created`, '%d.%m.%Y') as `created` FROM `ankets` WHERE `content_id` = '".$block['id']."' ORDER BY `order`"; $get_ankets = mysql_query($sql); if(mysql_num_rows($get_ankets)) { $ankets = array(); while($anket_row = mysql_fetch_assoc($get_ankets)) { $ankets[] = $anket_row; } } else { $ankets = false; } } } else { $block = false; } $module_data = $block; unset($block); //list of ankets if(!empty($ankets)) { $module_data['ankets'] = $ankets; unset($ankets); } //single anketa if(!empty($anketa)) { $module_data['anketa'] = $anketa; unset($anketa); //questions if($questions) { $module_data['anketa']['questions'] = $questions; $module_data['anketa']['question_amount'] = $question_amount; $module_data['anketa']['anketa_key'] = md5(rand(888, 8888)); // generating test key unset($questions, $question_amount); } //attempts if($attempts) { $module_data['anketa']['attempts'] = $attempts; $module_data['anketa']['attempts_amount'] = $attempts_amount; unset($attempts); } //full statistics if($fullstat) { $module_data['anketa']['fullstat'] = $fullstat; unset($fullstat); } // last attempt $module_data['anketa']['last_attempt'] = $last_attempt; unset($last_attempt); } break; case 'tests': //block $sql = "SELECT `id`, `name`, `real_name`, `description` FROM `testblocks` WHERE `subrazdel_id` = '".$moduls_set[$k]['id']."' LIMIT 1"; $get_block = mysql_query($sql); if(mysql_num_rows($get_block)) { $block = mysql_fetch_assoc($get_block); if($urlpath['itm']) { // single test // test $test_sql = "SELECT `id`, `type`, `real_name`, `description`, `users_only`, `is_published`, `timer`, `timer_amount`, `attempts_allowed`, `test_stopped` FROM `tests` WHERE `id` = '".$urlpath['itm']."' LIMIT 1"; $get_test = mysql_query($test_sql); if(mysql_num_rows($get_test)) { $test = mysql_fetch_assoc($get_test); // timer amount if($test['timer'] == 1 && empty($_SESSION['vew_test'])) { $time_sql = "SELECT `start_time` FROM `tests_attempts` WHERE `id` = '".$_SESSION['attempt_id']."' LIMIT 1"; $get_time = mysql_query($time_sql); $time_row = mysql_fetch_row($get_time); $start_time = $time_row[0]; $now = date('Y-m-d H:i:s'); $time_delta = strtotime(date('Y-m-d H:i:s')) - strtotime($start_time); $test['timer_val'] = $test['timer_amount'] - $time_delta; } // test questions $questions_sql = "SELECT `id`, `order`, `type`, `question_title`, `question_body`, `var1`, `var2`, `var3`, `var4`, `var5`, `var6`, `var7`, `var8`, `var9`, `var10`, `answear` FROM `tests_questions` WHERE `test_id` = '".$test['id']."' ORDER BY `order`"; $get_questions = mysql_query($questions_sql); if($question_amount = mysql_num_rows($get_questions)) { while($question_row = mysql_fetch_assoc($get_questions)) { // unserializing answear string if needed (depends on question type) switch($question_row['type']) { case 'chain': case 'sort': $question_row['answear'] = unserialize($question_row['answear']); if($question_row['type'] == 'chain') { //mixing variants (if "chain" type question) shuffle($question_row['answear']); } if($question_row['type'] == 'sort') { //srializing groups to use as a velue in a form-field $question_row['answear']['group_serialized'] = serialize($question_row['answear']['group']); // gathering all items (variants) and fake items in one array $all_items = array(); foreach($question_row['answear']['values'] as $key => $value) { foreach($question_row['answear']['values'][$key] as $item) { $all_items[] = $item; } } $question_row['answear']['all_items'] = array_merge($all_items, $question_row['answear']['fake']); shuffle($question_row['answear']['all_items']); } break; } $user_result_row['otvet_prefix'] = $otvet_prefix; $attempt_row['attempt_user_results'][$user_result_row['question_order']] = $user_result_row; } } // ordering array by question order ksort($attempt_row['attempt_user_results']); unset($user_result_row, $otvet_prefix); } #$sql_right_results = "SELECT `id` FROM `tests_results` WHERE `attempt_id` = '".$attempt_row['id']."' AND `right` = '1'"; #$get_right_results = mysql_query($sql_right_results); // store amount of questions inside 'attempts' array $attempt_row['questions_amount'] = mysql_num_rows($get_user_results); // store amount of right questions inside 'attempts' array if(!empty($right_amount)) { $attempt_row['right_amount'] = $right_amount; } else { $attempt_row['right_amount'] = 0; } // percent of right questions $attempt_row['right_percent'] = round($right_amount * 100 / $question_amount, 0); $attempts[] = $attempt_row; unset($right_amount, $attempt_row); } } else { // if no attempts $attempts = false; } } // full test statistics if($authorization['status'] == 'admin') { $sql_fullstat = "SELECT `id`, `attempt_number`, `user_id`, `name`, `surname`, `email`, `finish_time` FROM `tests_attempts` WHERE `test_id` = '".$test['id']."' ORDER BY `id` DESC"; $get_fullstat = mysql_query($sql_fullstat); if(mysql_num_rows($get_fullstat)) { while($fullstat_row = mysql_fetch_assoc($get_fullstat)) { // info about regitered user if($fullstat_row['user_id']) { $fullstat_row['user_status'] = 'registred'; $user = userInfo('', $fullstat_row['user_id']); $fullstat_row['name'] = $user['name']; $fullstat_row['lastname'] = $user['lastname']; $fullstat_row['surname'] = $user['surname']; $fullstat_row['email'] = $user['email']; // info about anonimoys user } else { $fullstat_row['user_status'] = 'guest'; } // date format to use fo filter $fullstat_row['date2row'] = date('Y-m-d', strtotime($fullstat_row['finish_time'])); // right answears amount $right_answears_sql = "SELECT `question_id`, `user_answear`, `right_answear`, `right` FROM `tests_results` WHERE `attempt_id` = '".$fullstat_row['id']."' AND `right` = 1"; $get_right_answears = mysql_query($right_answears_sql); $fullstat_row['right_answears'] = mysql_num_rows($get_right_answears); $fullstat_row['right_percent'] = round($fullstat_rt_amount) { $last_attempt['right_amount'] = $right_amount; $last_attempt['right_percent'] = round($right_amount * 100 / $question_amount, 0); } else { $last_attempt['right_amount'] = 0; $last_attempt['right_percent'] = 0; } } else { $last_attempt = false; } } } else { // if test doesn't esxist $test = false; } } else { // all the tetsts list $sql = "SELECT `id`, `type`, `name`, `main_img`, `real_name`, `description`, `users_only`, `is_published`, DATE_FORMAT(`created`, '%d.%m.%Y') as `created` FROM `tests` WHERE `content_id` = '".$block['id']."' ORDER BY `order`"; $get_tests = mysql_query($sql); if(mysql_num_rows($get_tests)) { $tests = array(); while($test_row = mysql_fetch_assoc($get_tests)) { $tests[] = $test_row; } } else { $tests = false; } } } else { $block = false; } $module_data = $block; unset($block); //list of tests if(!empty($tests)) { $module_data['tests'] = $tests; unset($tests); } //single test if(!empty($test)) { $module_data['test'] = $test; unset($test); //questions if($questions) { $module_data['test']['questions'] = $questions; $module_data['test']['question_amount'] = $question_amount; $module_data['test']['test_key'] = md5(rand(888, 8888)); // generating test key unset($questions, $question_amount); } //attempts if($attempts) { $module_data['test']['attempts'] = $attempts; $module_data['test']['attempts_amount'] = $attempts_amount; unset($attempts); } //full statistics if($fullstat) { $module_data['test']['fullstat'] = $fullstat; unset($fullstat); } // last attempt $module_data['test']['last_attempt'] = $last_attempt; unset($last_attempt); } break; case 'dashboard': // block $sql = "SELECT `id`, `name`, `real_name`, `description` FROM `dashboard_blocks` WHERE `subrazdel_id` = '".$moduls_set[$k]['id']."' LIMIT 1"; $get_block = mysql_query($sql); if(mysql_num_rows($get_block)) { $block = mysql_fetch_assoc($get_block); // screens $screens_sql = "SELECT `id`, `dashboard_id`, `name`, `real_name`, `main`, `icon_class`, `popup`, `access_rights`, `hidden` FROM `dashboard_screens` WHERE `dashboard_id` = '".$block['id']."' ORDER BY `order`"; $get_screens = mysql_query($screens_sql); if(mysql_num_rows($get_screens)) { // define if a dashboard has several screens or just one if(mysql_num_rows($get_screens) > 1) $block['multiscreen'] = true; unset($screen_row); } } else { $block['screens'] = false; } } else { $block = false; } $module_data = $block; unset($block); break; case 'forums': //block $sql = "SELECT `id`, `name`, `real_name`, `description` FROM `forum_blocks` WHERE `subrazdel_id` = '".$moduls_set[$k]['id']."' LIMIT 1"; $get_block = mysql_query($sql); if(mysql_num_rows($get_block)) { $block = mysql_fetch_assoc($get_block); // if we are inside a category if($urlpath['category']) { $category_sql = "SELECT `id`, `forum_id`, `name`, `main_img`, `real_name`, `description` FROM `forum_categories` WHERE `id` = '".$urlpath['category']."' LIMIT 1"; $get_category = mysql_query($category_sql); if(mysql_num_rows($get_category)) { $category_row = mysql_fetch_assoc($get_category); // checking access rights for subforum $chk_access = mysql_query("SELECT `users_only` FROM `forums` WHERE `id` = '".$category_row['forum_id']."' LIMIT 1"); $access = mysql_fetch_row($chk_access); if($access[0] == 1 && empty($authorization['auth'])) { $category_row['access'] = 'no'; } else { $category_row['access'] = 'yes'; } // if we are not inside a topic if(empty($urlpath['itm'])) { // list of topics $topics_sql = "SELECT * FROM `forum_topics` WHERE `forumcategory_id` = '".$category_row['id']."' ORDER BY `created` DESC"; $get_topics = mysql_query($topics_sql); if($category_row['topics_amount'] = mysql_num_rows($get_topics)) { while($topic_row = mysql_fetch_assoc($get_topics)) { // topic statistics $topic_row['posts_amount'] = db_param('forum_messages', 'topic_id', $topic_row['id']); if(!empty($topic_row['posts_amount%T') as `date`, `user_id`, `nick`, `name`, `surname`, `email`, `content`, `rating`, `upraters`, `downraters`, DATE_FORMAT(`last_edited`, '%d.%m.%Y, %T') as `last_edited`, `edit_reason`, `last_editor`, DATE_FORMAT(`last_moderated`, '%d.%m.%Y, %T') as `last_moderated`, `moderation_reason`, `last_moderator`, `deleted`, `delete_reason`, `post_number`, `thank_id` FROM `forum_messages` WHERE `id` = '".$urlpath['single']."' LIMIT 1"; } else { // list of posts inside a topic $posts_sql = "SELECT `id`, `forum_id`, `forumcategory_id`, `answearfor_id`, DATE_FORMAT(`date`, '%d.%m.%Y, %T') as `date`, `user_id`, `nick`, `name`, `surname`, `email`, `content`, `rating`, `upraters`, `downraters`, DATE_FORMAT(`last_edited`, '%d.%m.%Y, %T') as `last_edited`, `edit_reason`, `last_editor`, DATE_FORMAT(`last_moderated`, '%d.%m.%Y, %T') as `last_moderated`, `moderation_reason`, `last_moderator`, `deleted`, `delete_reason`, `post_number`, `thank_id` FROM `forum_messages` WHERE `topic_id` = '".$topic_row['id']."' ORDER BY `id`"; } $get_posts = mysql_query($posts_sql); if($topic_row['posts_amount'] = mysql_num_rows($get_posts)) { // creating array (registered users cache) if not exists if(!is_array($reg_users)) { $reg_users = array(); } while($post_row = mysql_fetch_assoc($get_posts)) { // users (post authors, editors) section (for registered users only) if(!empty($post_row['user_id'])) { // registered users // checking if the post author has been already placed to the array (registered users cache) if(array_key_exists($post_row['user_id'], $reg_users)) { // if user has been already cached $user = $reg_users[$post_row['user_id']]; } else { // if user hasn't been cached (it is user's 1st post in current topic) // get user info if($user_info = userInfo(false, $post_row['user_id'])) { // user avatar if(file_exists('grafika/razdeli/lc/'.$post_row['user_id'].'_avatar.jpg')) { $user_info['avatar'] = 'grafika/razdeli/lc/'.$post_row['user_id'].'_avatar.jpg'; } else { $user_info['avatar'] = 'grafika/razdeli/lc/no_avatar.jpg'; } // user total posts amount $user_info['total_posts'] = db_param('forum_messages', 'user_id', $post_row['user_id']); // attaching this user to user's cache array $reg_users[$post_row['user_id']] = array('id' => $post_row['user_id'], 'login' => $user_info['login'], 'email' => $user_info['email'], 'name' => $user_info['name'], 'surname' => $user_info['surname'], 'lastname' => $user_info['lastname'], 'soc_role' => $user_info['soc_role'], 'avatar' => $user_info['avatar'], 'total_posts' => $user_info['total_posts']); $user = $reg_users[$post_row['user_id']]; } else { // if user doesn't exist $user = false; } } // post last editor (user who has adited this post) if(!empty($post_row['last_editor'])) { // if there is an ID of user (then post has been edited) // if last post editor is already in users cache array if(array_key_exists($post_row['last_editor'], $reg_users)) { $editor = array('name' => $reg_users[$post_row['last_editor']]['name'], 'surname' => $reg_users[$post_row['last_editor']]['surname']); } else { //get editor if($editor_info = userInfo(false, $post_row['last_editor'])) { // attaching this user to user's cache array $reg_users[$post_row['last_editor']] = array('name' => $editor_info['name'], 'surname' => $editor_info['surname']); $editor = array('name' => $reg_users[$post_row['last_editor']]['name'], 'surname' => $reg_users[$post_row['last_editor']]['surname']); } else { $editor = false; } } } // we've finished with the post last editor } else { // unregitered users $user = array('email' => $post_row['email'], 'name' => $post_row['name'], 'surname' => $post_row['surname'], 'soc_role' => 'guest'); } // post last moderator (admin who has adited this post) if(!empty($post_row['last_moderator'])) { // if there is an ID of user (then post has been edited) // if last post moderator is already in users cache array if(array_key_exists($post_row['last_moderator'], $reg_users)) { $moderator = array('name' => $reg_users[$post_row['last_moderator']]['name'], 'surname' => $reg_users[$post_row['last_moderator']]['surname']); } else { //get moderator if($editor_info = userInfo(false, $post_row['last_moderator'])) { // attaching this user to user's cache array $reg_users[$post_row['last_moderator']] = array('name' => $editor_info['name'], 'surname' => $editor_info['surname']); $moderator = array('name' => $reg_users[$post_row['last_moderator']]['name'], 'surname' => $reg_users[$post_row['last_moderator']]['surname']); } else { $moderator = false; } } } // we've finished with the post last moderator // attaching user info to the post info $post_row['user_info'] = $user; // about post author $post_row['editor_info'] = $editor; // about post editor $post_row['moderator_info'] = $moderator; // about post moderator unset($user, $editor, $moderator); //end of users section // if it is an answear - attaching "original" post $current_post_stack[] = $post_row; // tamprory stack of messages - to choose original message if(!empty($post_row['answearfor_id']) && empty($urlpath['single'])) { // if this post is an answear foreach($current_post_stack as $kk => $vv) { // looking through tamprory stack of messages if($post_row['answearfor_id'] == $current_post_stack[$kk]['id']) { $post_row['original_post'] = array('id' => $current_post_stack[$kk]['id'], 'post_number' => $current_post_stack[$kk]['post_number'], 'content' => $current_post_stack[$kk]['content'], 'date' => $current_post_stack[$kk]['date'], 'name' => $current_post_stack[$kk]['user_info']['name'], 'surname' => $current_post_stack[$kk]['user_info']['surname']); } } } $posts[] = $post_row; } } else { $posts = false; } $topic_row['posts'] = $posts; unset($posts, $current_post_stack); $topic = $topic_row; } else { $topic = false; } } if(!empty($topic)) { $category_row['current_topic'] = $topic; unset($topic); } $category = $category_row; } else { $category = false; } } // if we are in the root of a forum else { // subforums $subforum_sql = "SELECT `id`, `type`, `name`, `main_img`, `real_name`, `description`, `users_only`, `opened_for`, `is_closed`, DATE_FORMAT(`created`, '%d.%m.%Y') as `created` FROM `forums` WHERE `content_id` = '".$block['id']."' ORDER BY `order`"; $get_subforums = mysql_query($subforum_sql); if(mysql_num_rows($get_subforums)) { while($subforum_row = mysql_fetch_assoc($get_subforums)) { //categories if($subforum_row['users_only'] == 1 && empty($authorization['auth'])) { $subforum_row['access'] = 'no'; $categories = false; } else { $subforum_row['access'] = 'yes'; $categories_sql = "SELECT * FROM `forum_categories` WHERE `forum_id` = '".$subforum_row['id']."' ORDER BY `order`"; $get_categories = mysql_query($categories_sql); if(mysql_num_rows($get_categories)) { while($category_row = mysql_fetch_assoc($get_categories)) { // category statistics $category_row['topics_amount'] = db_param('fo db_param('forum_messages', 'forum_id', $subforum_row['id']); // amount of posts $subforums[] = $subforum_row; unset($subforum_row); } } else { $subforums = false; } } } else { $block = false; } $module_data = $block; unset($block); // subforums if($subforums) { $module_data['subforums'] = $subforums; unset($subforums); } // current category if($category) { $module_data['current_category'] = $category; unset($category); } break; case 'sitemap': if(!empty($navigation['main_menu'])) { $block = $navigation['main_menu']; $sql = "SELECT `id`, `parent`, `name`, `real_name`, `type`, `access`, `hidden` FROM `razdeli` WHERE `parent` <> 'root' AND `hidden` <> '1' ORDER BY `order`"; $get_subrazdels = mysql_query($sql); if(mysql_num_rows($get_subrazdels)) { while($subrazdel_row = mysql_fetch_assoc($get_subrazdels)) { foreach($block as $punkt_k => $punkt_v) { if($block[$punkt_k]['razdel'] == $subrazdel_row['parent']) { $subpunkt_access = checkAccessRights($subrazdel_row['access']); if($subpunkt_access[0] == false or ($subpunkt_access[0] == true && $subpunkt_access[1] == true)) { /* if category */ if($subrazdel_row['type'] == 'category') { $category_sql = "SELECT `id`, `parent`, `name`, `real_name`, `type`, `access`, `hidden` FROM `razdeli` WHERE `parent` = '".$subrazdel_row['name']."' AND `hidden` <> '1' ORDER BY `order`"; $get_category = mysql_query($category_sql); if(mysql_num_rows($get_category)) { while($category_punkt = mysql_fetch_assoc($get_category)) { $subrazdel_row['category_punkts'][] = $category_punkt; } unset($category_punkt); } else { $subrazdel_row['category_punkts'] = false; } } $block[$punkt_k]['subpunkts'][] = $subrazdel_row; unset($subpunkt_access); } } } } } } else { $block = false; } $module_data = $block; break; case 'spoilers': // block $sql = "SELECT `id`, `name`, `real_name`, `description` FROM `spoiler_blocks` WHERE `subrazdel_id` = '".$moduls_set[$k]['id']."' LIMIT 1"; $get_block = mysql_query($sql); if(mysql_num_rows($get_block)) { $block = mysql_fetch_assoc($get_block); // spoilers $spoilers_sql = "SELECT `id`, `content_id`, `title`, `subtitle`, `main_img`, `content`, `show_fullview`, DATE_FORMAT(`created`, '%d.%m.%Y') as `created`, `uploaded_docs`, `slideshows`, `polls`, `allow_comments`, `commented`, `keywords` FROM `spoilers` WHERE `content_id` = '".$block['id']."' ORDER BY `order`"; $get_spoilers = mysql_query($spoilers_sql); if(mysql_num_rows($get_spoilers)) { while($spoiler_row = mysql_fetch_assoc($get_spoilers)) { $appendix_params = array('module_type' => $moduls_set[$k]['type'], 'appendix_types' => array('poll', 'documents', 'files')); $appendix = new appendix($spoiler_row['id'], $appendix_params['module_type']); $spoiler_row['appendix'] = $appendix->pack($appendix_params['appendix_types']); $block['spoilers'][] = $spoiler_row; unset($appendix_params, $appendix, $spoiler_row); } } else { $block['spoilers'] = false; } } else { $block = false; } $module_data = $block; unset($block); break; case 'timetable': // block $sql = "SELECT `id`, `name`, `real_name`, `description`, `time_column`, `class_column`, DATE_FORMAT(`day1_date`, '%d.%m.%Y') as `day1_date`, DATE_FORMAT(`day2_date`, '%d.%m.%Y') as `day2_date`, DATE_FORMAT(`day3_date`, '%d.%m.%Y') as `day3_date`, DATE_FORMAT(`day4_date`, '%d.%m.%Y') as `day4_date`, DATE_FORMAT(`day5_date`, '%d.%m.%Y') as `day5_date`, DATE_FORMAT(`day6_date`, '%d.%m.%Y') as `day6_date`, DATE_FORMAT(`day7_date`, '%d.%m.%Y') as `day7_date`, `note`, DATE_FORMAT(`created`, '%d.%m.%Y, %T') as `created` FROM `timetable` WHERE `subrazdel_id` = '".$moduls_set[$k]['id']."' LIMIT 1"; $get_block = mysql_query($sql); if(mysql_num_rows($get_block)) { $block = mysql_fetch_assoc($get_block); // lessons for($i = 1; $i <= 7; $i++) { if(empty($block['day'.$i.'_date']) or $block['day'.$i.'_date'] === '00.00.0000'){ $block['day'.$i.'_date'] = false; } $lessons_sql = "SELECT `id`, `order`, `subject_custom`, `subject_id`, `teacher_custom`, `teacher_id`, `class_custom`, `class_id`, `place`, `time_start`, `time_finish`, `type`, `note` FROM `timetable_tables` WHERE `content_id` = '".$block['id']."' AND `weekday_index` = '".$i."' ORDER by `order`"; $get_lessons = mysql_query($lessons_sql); if(mysql_num_rows($get_lessons)) { while($lesson_row = mysql_fetch_assoc($get_lessons)) { // paste empty rows if lessons have breaks ("windows") // current iteration number if(empty($iteration)) { $iteration = 1; } else { $iteration++; } while($iteration < $lesson_row['order']) { $block['lessons'][$i][] = array('subject_custom' => '-'); $iteration++; } // we've finished with paste empty rows $block['lessons'][$i][] = $lesson_row; } unset($iteration); // reset variable for empty rows paste } else { $lessons = false; } } // paste empty rows to the end of lessons list - to make quantity of rows equal in each day if(!empty($block['lessons'])) { foreach($block['lessons'] as $kkk => $vvv) { // array with amounts of lessons in each day $amounts[] = count($block['lessons'][$kkk]); } // max amount of lessons $max_amount = max($amounts); // paste rows foreach($block['lessons'] as $kkk => $vvv) { while($iteration = count($block['lessons'][$kkk]) < $max_amount) { $block['lessons'][$kkk][] = array('subject_custom' => '-'); $iteration++; } } unset($iteration); } } else { $block = false; } $module_data = $block; unset($block); break; case 'techcard': // block $sql = "SELECT `id`, `name`, `real_name`, `description`, DATE_FORMAT(`created`, '%d.%m.%Y, %T') as `created`, `allowpdf` FROM `techcardsbl` WHERE `subrazdel_id` = '".$moduls_set[$k]['id']."' LIMIT 1"; $get_block = mysql_query($sql); if(mysql_num_rows($get_block)) { $block = mysql_fetch_assoc($get_block); /* if we are in techcard view mode */ if(!empty($urlpath['itm'])) { $techcard_sql = "SELECT * FROM `techcards` WHERE `id` = '".$urlpath['itm']."' LIMIT 1"; $get_card = mysql_query($techcard_sql); if(mysql_num_rows($get_card)) { $card_row = mysql_fetch_assoc($get_card); // lesson stages $stages_sql = "SELECT * FROM `techcards_stages` WHERE `techcard_id` = '".$card_row['id']."' ORDER BY `order`"; $get_stages = mysql_query($stages_sql); if(mysql_num_rows($get_stages)) { // defining column names to check for existance in current techcard $fields = array('stage_target', 'stage_length', 'lichn_activity', 'lichn_formir', 'pozn_activity', 'pozn_formir', 'commun_activity', 'commun_formir', 'regul_activity', 'regul_formir'); while($stage_row = mysql_fetch_assoc($get_stages)) { $card_row['stages'][] = $stage_row; // define columns for lesson stages table foreach($fields as $fieldkey => $field) { if(!empty($stage_row[$field])) { $card_row['stages_fieldset'][$field] = 1; // column index - indicates position of the column relative to the end of the table if(empty($card_row['stages_table_params']['last_column_index'])) { $card_row['stages_table_params']['last_column_index'] = $fieldkey; } // if column is closer to the end of the table - updating params if($card_row['stages_table_params']['last_column_index'] < $fieldkey) { $card_row['stages_table_params']['last_column'] = $field; $card_row['stages_table_params']['last_column_index'] = $fieldkey; } } } } // defining params to format stages table grid // calculating amount of columns in student's activity section of the stages table $student_fields = array_slice($fields, 2); foreach($student_fields as $field) { if($card_row['stages_fieldset'][$field] == 1) { if(empty($studentfields_amount)) { $studentfields_amount = 1; } else { $studentfields_amount++; } } } if(!empty($studentfields_amount)) { $card_row['stages_table_params']['studentfields_amount'] = $studentfields_amount; $card_row['stages_table_params']['header_rowspan'] = 3; } unset($fields, $student_fields, $studentfields_amount); } else { $card_row['stages'] = false; } // we've finished with lesson stages $block['current_techcard'] = $card_row; } else { $block['current_techcard'] = false; } /* if we are in the root of module */ } else { // techcard list $techcards_sql = "SELECT `id`, `content_id`, `lesson_num`, `subject_custom`, `subject_id`, `class_custom`, `class_id`, `class`, `lesson_topic`, `type_custom`, `type_id` FROM `techcards` WHERE `content_id` = '".$block['id']."' ORDER BY `order`"; $get_techcards = mysql_query($techcards_sql); if(mysql_num_rows($get_techcards)) { while($techcards_row = mysql_fetch_assoc($get_techcards)) { $block['techcards'][] = $techcards_row; } } else { // if no techcards $block['techcards'] = false; } } } else { $block = false; } $module_data = $block; unset($block); break; default: $sql = false; break; } //get module data if(!$module_data) { if($sql) { $module_data = array(); $get_data = mysql_query($sql); if(mysql_num_rows($get_data)) { while($row = mysql_fetch_assoc($get_data)) { //appendix if(is_array($appendix_params)) { $appendix = new appendix($row['id'], $appendix_params['module_type']); $row['appendix'] = $appendix->pack($appendix_params['appendix_types']); unset($appendix_params); } //comments if(is_array($comments_params)) { $comments = new comments($row['id'], $comments_params['subrazdel_id'], $comments_params['parent_id']); if($comments_params['amount_only'] === true) { //if we want to know only amount of comments $row['comments']['total_amount'] = $comments->get_comments_amount(); } else { // if we need full tree of comments $row['comments'] = $comments->comment(); } unset($comments); } $module_data[] = $row; } } } else { $module_data = false; } } //attaching module content to modules array $moduls_set[$k]['data'] = $module_data; // pagination if(is_array($pagination_params)) { /* echo $pagination_params['pages_amount'].'_'.$pagination_params['amount_hidden']; die; */ for($i = 1; $i <= $pagination_params['amount_hidden']; $i++){ /* $row[] = array('role' => 'fake'); */ array_push($moduls_set[$k]['data'], array('role' => 'fake')); } } unset($module_data); } } } /** /* if we are in a profile */ if($navigation['razdel'] == 'lc') { // if we are looking trough another user profile if(!empty($urlpath['itm'])) { /* TODO: take info from the DB */ } else { // if it is user's own profile $moduls_set['profile'] = $_SESSION['usr_arr']; } // current user avatar if (file_exists('grafika/razdeli/lc/'.$moduls_set['profile']['id'].'_avatar.jpg')) { $moduls_set['profile']['avatar'] = 'grafika/razdeli/lc/'.$moduls_set['profile']['id'].'_avatar.jpg'; $moduls_set['profile']['avatar_filename'] = $moduls_set['profile']['id'].'_avatar.jpg'; } else { $moduls_set['profile']['avatar'] = 'grafika/razdeli/lc/no_avatar.jpg'; } // main profile foto if (file_exists('grafika/razdeli/lc/'.$moduls_set['profile']['id'].'_main_foto.jpg')) { $moduls_set['profile']['foto'] = 'grafika/razdeli/lc/'.$moduls_set['profile']['id'].'_main_foto.jpg'; $moduls_set['profile']['foto_filename'] = $moduls_set['profile']['id'].'_main_foto.jpg'; } else { $moduls_set['profile']['foto'] = 'grafika/razdeli/lc/no_foto.jpg'; } } $moduls['moduls_set'] = $moduls_set; unset($default_content, $moduls_set); /** * SITE FOOTER DATA */ $footer_data = array(); /** * footer credits */ $sql = "SELECT `id`, `order`, `text`, `link` FROM `footer_credits` WHERE `hidden` <> '1' ORDER BY `order`"; $get_data = mysql_query($sql); if(mysql_num_rows($get_data)) { while($row = mysql_fetch_assoc($get_data)) { $footer_data['credits'][] = $row; } } else { $footer_data['credits'] = false; } /** * footer banners (scripts, etc) */ $sql = "SELECT `id`, `rname`, `order`, `image`, `link`, `code` FROM `footer_banners` WHERE `hidden` <> '1' ORDER BY `order`"; $get_data = mysql_query($sql); if(mysql_num_rows($get_data)) { while($row = mysql_fetch_assoc($get_data)) { $footer_data['banners'][] = $row; } } else { $footer_data['banners'] = false; } unset($sql, $get_data, $row); #if ($_SESSION['admin'] == 'jaguar') { #if ($_SESSION['user'] == 'flaks') { #echo '
';
	#print_r($moduls_set);
	#print_r($urlpath);
	#print_r($moduls);
	#print_r($user_groups);
	#print_r($configa);
	#print_r($_SESSION);
	#print_r($authorization);
	#echo $admin_panel;
	#print_r($navigation);
	#print_r($global_vars);
	#print_r($blocks);
	#echo '
'; #} /** * * QUERY RESULT * */ /** *define template with site skeleton */ $template = $twig->loadTemplate('carcas.html'); /** *render skeleton (carcas.html) */ echo $template->render(array('urlpath' => $urlpath, 'session' => $_SESSION, 'auth' => $authorization, 'global' => $global_vars, 'user_groups' => $user_groups, 'configa' => $configa, 'admin_panel' => $admin_panel, 'navigation' => $navigation, 'blocks' => $blocks, 'moduls' => $moduls, 'footer' => $footer_data)); unset($authorization, $global_vars, $user_groups, $configa, $admin_panel, $navigation, $blocks, $moduls, $footer_data);