<?php debug_backtrace() || die("Direct access not permitted."); ?> <?php // error_reporting(0); require_once 'main/init.php'; $user_type = user_type(); if ($user_type == 'admin' || $user_type == 'official') { require_once 'main/main.php'; } elseif ($user_type == 'teacher') { require_once 'main/teachers/main.php'; } elseif ($user_type == 'principal') { require_once 'main/teachers/main.php'; } elseif ($user_type == 'student') { require_once 'main/students/main.php'; } elseif ($user_type == 'parent') { require_once 'main/parents/main.php'; } //adding css add_css([get_plugin_dir() . '/css/style.css', get_plugin_dir() . '/css/datepicker.css']); //adding js into header add_js_header(get_plugin_dir() . '/js/functions.js'); //adding js into footer add_js_footer([get_plugin_dir() . '/js/script.js', get_plugin_dir() . '/js/datepicker.js']);
private function compress_js() { $current_file = sha1(date('Ymd')); $path_to_current_file = SERVER_ROOT . '/js/header_' . $current_file . '.js'; if (!file_exists($path_to_current_file)) { $file_content = ''; foreach ($GLOBALS['data']['js_header'] as $key => $js) { $file_content .= file_get_contents(SERVER_ROOT . $js['path_to_file']); if ($file_content) { unset($GLOBALS['data']['js_header'][$key]); } } if (count($GLOBALS['data']['js_header']) < 1) { unset($GLOBALS['data']['js_header']); } $file_content = preg_replace('!/\\*[^*]*\\*+([^/][^*]*\\*+)*/!', '', $file_content); $file_content = str_replace(array('\\r', '\\n'), '', $file_content); $file_content = str_replace('{ ', '{', $file_content); $file_content = str_replace(' }', '}', $file_content); $file_content = str_replace('; ', ';', $file_content); $file_content = str_replace(', ', ',', $file_content); $file_content = str_replace(' {', '{', $file_content); $file_content = str_replace('} ', '}', $file_content); $file_content = str_replace(': ', ':', $file_content); $file_content = str_replace(' ,', ',', $file_content); $file_content = str_replace(' ;', ';', $file_content); $file_content = str_replace(array("\r\n", "\r", "\n", "\t", ' ', ' ', ' '), '', $file_content); $old_js_find = SERVER_ROOT . '/js/header_*.js'; $old_js_files = glob($old_js_find); foreach ($old_js_files as $file) { unlink($file); } file_put_contents($path_to_current_file, $file_content); } $path_to_current_file = SERVER_ROOT . '/js/footer_' . $current_file . '.js'; if (!file_exists($path_to_current_file)) { $file_content = ''; foreach ($GLOBALS['data']['js_footer'] as $key => $js) { $file_content .= file_get_contents(SERVER_ROOT . $js['path_to_file']); if ($file_content) { unset($GLOBALS['data']['js_footer'][$key]); } } if (count($GLOBALS['data']['js_footer']) < 1) { unset($GLOBALS['data']['js_footer']); } $file_content = preg_replace('!/\\*[^*]*\\*+([^/][^*]*\\*+)*/!', '', $file_content); $file_content = str_replace('{ ', '{', $file_content); $file_content = str_replace(' }', '}', $file_content); $file_content = str_replace('; ', ';', $file_content); $file_content = str_replace(', ', ',', $file_content); $file_content = str_replace(' {', '{', $file_content); $file_content = str_replace('} ', '}', $file_content); $file_content = str_replace(': ', ':', $file_content); $file_content = str_replace(' ,', ',', $file_content); $file_content = str_replace(' ;', ';', $file_content); $file_content = str_replace(array("\r\n", "\r", "\n", "\t", ' ', ' ', ' '), '', $file_content); $old_js_find = SERVER_ROOT . '/js/footer_*.js'; $old_js_files = glob($old_js_find); foreach ($old_js_files as $file) { unlink($file); } file_put_contents($path_to_current_file, $file_content); } unset($GLOBALS['data']['js_header']); unset($GLOBALS['data']['js_footer']); add_js_footer('/js/footer_' . $current_file . '.js'); add_js_header('/js/header_' . $current_file . '.js'); }