USER_NAME_LENGTH){ $names = explode(' ', $username ); // check if firstname is not to big else lastname not to big if(strlen($names[0]) <= USER_NAME_LENGTH){ $username = $names[0]; }elseif(strlen($names[1]) <= USER_NAME_LENGTH) { $username = $names[1]; } } return $username; } /* * Name : get_file_extension($file_name, &$mimetype) * Parameters : - file_name * - mimetype * Description : Get extenstion of the file */ function get_file_extension($file_name, &$mimetype) { // Get extenstion of the filename $ext = strtolower(substr(strrchr($file_name,'.'),1)); // Set mimetype switch($ext){ case 'pdf': $mimetype = 'application/pdf'; break; case 'doc': $mimetype = 'application/msword'; break; case 'docx': $mimetype = 'application/msword'; break; case 'odt': $mimetype = 'application/vnd.oasis.opendocument.text'; break; case 'ods': $mimetype = 'application/vnd.oasis.opendocument.spreadsheet'; break; case 'xls': $mimetype = 'application/vnd.ms-excel'; break; case 'mp3': $mimetype = 'audio/mpeg'; break; case 'mp4': $mimetype = 'video/mp4'; break; case 'txt': $mimetype = 'application/msword'; break; case 'jpg': $mimetype = 'image/jpeg'; break; case 'jpeg': $mimetype = 'image/jpeg'; break; case 'png': $mimetype = 'image/png'; break; case 'gif': $mimetype = 'image/gif'; break; case 'csv': $mimetype ='text/csv'; break; case 'html': $mimetype ='text/html'; break; case 'flv': $mimetype ='video/x-flv'; break; case 'mpg': $mimetype - 'video/mpeg'; break; case 'avi': $mimetype - 'video/x-msvideo'; break; case 'wma': $mimetype = 'audio/x-ms-wma'; break; default: $mimetype = "not supported"; break; } return $ext; } /* * Name : delete_characters($name) * Parameters : - name * Description : Delete unwanted characters */ function delete_characters($name) { // Characters to delete from the string $deleted_chars = array("\"","?","*",":", "|", "<", ">"," ","#","&","'"); $new_name = str_replace($deleted_chars, "_", $name); // delete backslash return stripslashes($new_name); } /* * Name : cut_name($name) * Parameters : - name * Description : Cut name */ function cut_name($name, $cut_size=20) { if(strlen($name) > $cut_size ){ $new_name = substr($name, 0 , $cut_size); $new_name .= ".."; return $new_name; } return $name; } /* * Name : check_project($project_id) * Parameters : - project_id * Description : Check if user have the correct project rights */ function check_project($project_id){ $project = db_fetch_project($project_id,"",1); // Check for non-released/released projects // normal project => planning status must be finished (and non-RS3000) // rc project => planning and design status must be validated if (($project['status'] != "afgesloten") && ((($project['type'] == "normaal") && ($project['pstatus'] == "gereed"))) ||(($project['type'] == "rc") && (($project['pstatus'] == "gevalideerd") && ($project['ostatus'] == "gevalideerd")))) { return 1; } return 0; } /* * Name : preload_images($path) * Parameters : - path * Description : preload the images from the selected images path */ function preload_images($path){ GLOBAL $_PAGE_INFO; // Check if images are loaded already if ((!isset($_SESSION[$_PAGE_INFO['id']]['preload_images'][' ' . $path . ' '])) || ($_SESSION[$_PAGE_INFO['id']]['preload_images'][' ' . $path . ' '] != realpath("app/html/images/" . $path . "/"))) { // Get all filenames of the images $file_images = get_all_files("app/html/images/" . $path . "/",""); // Create divs to pre load al images once foreach($file_images as $file_image){ echo "
"; } $_SESSION[$_PAGE_INFO['id']]['preload_images'][' ' . $path . ' '] = realpath("app/html/images/" . $path . "/"); } } /* * Name : place_header($info) * Parameters : $info[text_header] * $info[text_login_button] * $info[id_login_button] * $info[id_connection_icon] * Description : place header */ function place_header($info){ global $_PAGE_INFO; echo "
"; // Check if text_header is not empty. if empty then get text for the header from javascript if(!empty($info['text_header'])){ echo"
" . strtoupper($info['text_header']) . "
"; }else{ // Check if id must be set (RS3000) if(isset($info['header_id']) && !empty($info['header_id'])){ echo"
"; }else{ echo"
"; } } echo"
" . strtoupper(app_($info['text_login_button'])) . "
"; } /* * Name : place_footer($info) * Parameters : $info[text_version] * $info[text_version_number] * $info[id_footer_button_one] * $info[id_footer_button_two] * $info[id_footer_button_three] * $info[id_footer_button_four] * Description : place footer */ function place_footer($info){ GLOBAL $_PAGE_INFO; echo"
" . strtoupper("" . $info['text_version'] . ": " . ((is_ReleaseCandidate()) ? $_SESSION[$_PAGE_INFO['id']]['release_dir'] : $info['text_version_number'] )) . "
". strtoupper(checkSizeUsername($_SESSION[$_PAGE_INFO['id']]['login']['user']['name'])) ."
"; } /* * Name : parse_rtstatus($zkl_status) * Parameters : $zkl_status * * Description : partse the real time status into array */ function parse_rtstatus($zkl_status) { // Remove tags $tmp = explode('},{',$zkl_status); if (is_array($tmp)) { unset($zkl_status); // Remove tags $tmp[0] = str_replace("/*ZKLsu1.0*/ZKL_Status=[{", "", $tmp[0]); $tmp[sizeof($tmp)-1] = str_replace("}];", "", $tmp[sizeof($tmp)-1]); // Split to array for($i=0; $i 0) { if (!empty($key)) { $mapping = array(); foreach ($array as $k => $v) { $sort_key = ''; if (!is_array($key)) { $sort_key = $v[$key]; } else { // @TODO This should be fixed, now it will be sorted as string foreach ($key as $key_key) { $sort_key .= $v[$key_key]; } $sort_flags = SORT_STRING; } $mapping[$k] = $sort_key; } asort($mapping, $sort_flags); $sorted = array(); foreach ($mapping as $k => $v) { $sorted[] = $array[$k]; } return $sorted; } } return $array; } /** * This function will translate and add slashes when necessary* */ function app_($str){ return specialchars(htmlspecialchars(_($str), ENT_QUOTES)); } /** * Includes the js portal variable */ function includeJSPortalVariable() { GLOBAL $_PAGE_INFO; $output = ''; // Check if its not the DVP app if (!stristr($_SERVER['HTTP_USER_AGENT'],"_DVP")) { $isPortal = isset($_SESSION[$_PAGE_INFO['id']]['APP_PORTAL']) ? 1:0; $output = " "; } return $output; } //invoer feedback goed maken /** * Shows the provided toast message to the user in a toast alert * * @param string $toastMsg The error message to display */ function showToastMsg($toastMsg) { echo ""; } ?>