How to run an existing moodle environment on a Testbed server - php

I've recently started working as a Junior Network Engineer and as my first task I was assigned to make a simple modification on php.ini file in moodle. Therefore, first I setup moodle environment on my laptop with Apache2 and Ubuntu 20.4. Then I tested my modification locally. That was ok.
However, before make the same changes to the live server, I wanted to test that on the Testbed server as well. A replica of the live moodle server has been uploaded into the testbed server. However, initially the problem was that whenever I tried to run moodle on the testbed server, that redirected into the live server, and therefore I could not test my modifications.
Later I made few changes in the 'config.php' and 'login.php' in moodle directory, which have been presented in the images. With those changes, now the login page can be run locally on the testbed server. But still, when I try to login to the system, the page redirects to the live webpage.
Therefore, I appreciate it very much if someone could help me resolve this issue.
Thank you!
Testbed server information:
OS- CentOS 6.5
PHP version-7.2.30
server-Apache2
Moodle version-3.6.4
config.php
login.php
<!DOCTYPE html>
<html dir="ltr" xml:lang="en" lang="en">
<head>
<title>TestBed Server ULMS | ***</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="assets/all.css">
<link href="assets/css_002.css" rel="stylesheet" type="text/css">
<link href="assets/css.css" rel="stylesheet" type="text/css">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script type="text/javascript" charset="utf-8" async="" data-requirecontext="_" data-requiremodule="core/first"
src="assets/first.js"></script>
<script type="text/javascript" charset="utf-8" async="" data-requirecontext="_" data-requiremodule="core/event"
src="assets/event.js"></script>
<script type="text/javascript" charset="utf-8" async="" data-requirecontext="_" data-requiremodule="jquery"
src="assets/jquery-3.js"></script>
</head>
<body id="page-login-index"
class="format-site path-login gecko dir-ltr lang-en yui-skin-sam yui3-skin-sam moodle-wit-ie pagelayout-login course-1 context-1 notloggedin jsenabled"
style="background-image: url(''); background-repeat: no-repeat; background-position: center center;">
<div id="page-wrapper" class="login-page-wrapper">
<div>
<a class="sr-only sr-only-focusable" href="#maincontent">Skip to main content</a>
</div>
<script type="text/javascript" src="assets/yui_combo_004.php"></script>
<script type="text/javascript" src="assets/javascript-static.js"></script>
<style>
.btn-info {
color: #fff;
background-color: #5bc0de !important;
border-color: #5bc0de !important;
}
</style>
<div id="page" class="container-fluid mt-0" style="padding-left: 0px; padding-right: 0px;">
<div id="page-content" class="row">
<div id="region-main-box" class="col-12">
<section id="region-main" class="col-12">
<div id="login__banner">
<img id="login__banner-logo" src="assets/lms_logo_aquanas.png">
</div>
<span class="notifications" id="user-notifications"></span>
<div role="main"><span id="maincontent"></span>
<div class="my-1 my-sm-5"></div>
<div class="row justify-content-center">
<div class="login__container" style="margin-top: 130px;">
<div class="card">
<div class="card-block login-card-block">
<div class="card-title text-xs-center">
<!-- <div id="login__moodle-logo" style="height: 70px;">
<h2 class="text-center"></h2>
</div>-->
<!--<div id="login__avatar-container" style="display: none;">
<img src="assets/no_profile_img.jpg">
</div>-->
</div>
<div class="row justify-content-md-center">
<div class="col-md-10">
<form class="mt-3" action="https://192.168.50.20/moodle/login/index.php" method="post" id="login" name="login">
<div class="form-group">
<label for="username" class="sr-only">
Username
</label>
<input name="username" id="username" class="form-control" placeholder="Student Number / Staff Username" type="text">
</div>
<div class="form-group">
<label for="password" class="sr-only">Password</label>
<input name="password" id="password" value="" class="form-control" placeholder="Password" type="password">
</div>
<button type="submit" class="btn btn-primary btn-block mt-3" id="loginbtn">Log in
</button>
</form>
</div>
<div class="col-md-10">
<div class="forgetpass mt-3">
<p><a href="https://192.168.50.20/login/forgot_password.php">Forgotten
your username or password?</a></p>
</div>
<!--<div id="login__support-container">
<a class="login__support login__student-support" href="http://***" target="_blank" style="text-align: center;"><img src="asset$
<a class="login__support login__student-support" href="http://***" target="_blank" style="text-align: center;"><img src="asset$
</div>-->
<!--<div id="login__support-container">
<a class="login__support login__student-support"
href="#"
target="_blank"><img
src="assets/support-icon.png"><span
class="login__support-text">Student Support</span></a>
<a class="login__support login__staff-support"
href="#"
target="_blank"><img
src="assets/academic-icon.png"><span
class="login__support-text">Staff Support</span></a>
</div>-->
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
</div>
</div>
</div>
</div>
<div>
<p style="text-align: center; font-size: 10px">Powered by <a href="http://www.moodle.org" target="_blank"><img id="moodle" src="assets/moodlelogo.png" style="height: 20px; vertical-align:$
<p style="text-align: center; font-size: 10px"></p>
</div>
<div id="yui3-css-stamp" style="position: absolute !important; visibility: hidden !important" class=""></div>
<script type="text/javascript" src="assets/require.js"></script>
</body>
</html>

Related

Cannot Add Background Image in PHP

I have used following code to add a background image to my PHP file.
body {
background-image:url('background.png');
background-color: #F0F8FF;
}
But I can see the color only changed not the image. Can someone help me to solve this? Does this due to the image resolutions? I exported the image from microsoft powerpoint. Do I need to consider that as well? Are there any method to find whether the issue with my code or my picture.
I have pasted my whole code.
<?php
session_start();
?>
<!DOCTYPE html>
<html>
<head>
<title>Library Management System</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
</head>
<body>
<br />
<div class="container" style="width:700px;">
<h3 align="center">Management System</h3><br />
<br />
<br />
<br />
<br />
<br />
<?php
if(isset($_SESSION['username']))
{
?>
<div align="center">
<h1>Welcome to Dialog G-Tech Library</h1><br />
<div class="bar" align="center">
Logout
</div>
</div>
<?php
}
else
{
?>
<div id="loginModal" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Login</h4>
</div>
<div class="modal-body">
<label>Username</label>
<input type="text" name="username" id="username" class="form-control" />
<br />
<label>Password</label>
<input type="password" name="password" id="password" class="form-control" />
<br />
<button type="button" name="login_button" id="login_button" class="btn btn-warning">Login</button>
</div>
</div>
</div>
</div>
<?php
}
?>
</div>
<br />
</body>
<style type="text/css">
.bar {
overflow: hidden;
background-color: #87CEEB;
}
.bar a {
float: left;
color: black;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 17px;
}
.bar a:hover {
background-color: #ddd;
color: black;
}
body {
background-image:url('background.png');
background-color: #F0F8FF;
}
</style>
</html>
<div id="loginModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Login</h4>
</div>
<div class="modal-body">
<label>Username</label>
<input type="text" name="username" id="username" class="form-control" />
<br />
<label>Password</label>
<input type="password" name="password" id="password" class="form-control" />
<br />
<button type="button" name="login_button" id="login_button" class="btn btn-warning">Login</button>
</div>
</div>
</div>
</div>
Sometimes the cache won’t realize that changes have been made to your website. A hard refresh is a way of clearing the browser’s cache for a specific page, to force it to load the most recent version of a page. Sometimes, when changes are made to the website, they don’t register immediately due to caching. A hard refresh will usually fix this, though occasionally completely clearing the cache is necessary.
Right Click on the refresh button and click on Empty Cache and Hard Reload and check its working or not

make textboxes and buttons occupy the entire div

I want both the textbox and the button to occupy the entire div (which is colored) only using bootstrap. Here I show you a screenshot of my screen: https://postimg.cc/yJcPtVSg. I have tried several things (put the col-12) but I have not been successful. This is my code:
<html>
<head>
<meta charset="UTF-8">
<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="css/jquery-ui.css" />
<script src="js/jquery-1.9.1.js"></script>
<script src="js/jquery-ui.js"></script>
<LINK REL=StyleSheet HREF="css2/bootstrap.css" TYPE="text/css">
</head>
<body>
<div class="container" style='height:600px;'>
<div class='row h-100 '>
<div class='col bg-danger my-auto d-flex justify-content-center alig-items-center '>
<form action="lineas.php" method="post">
<div class ='row m-3 '>
<?php echo("Elige origen: ");?>
<input type="text" id="origen" name="origen" class="form-control ">
</div>
<div class ="row m-3">
<?php echo("Elige destino: ");?>
<input type="text" id="destino" name="destino" class="form-control">
</div>
<div class ="row m-3">
Selecciona una fecha: <input type="text" id="datepicker" name="fecha" class="form-control">
</div>
<div class ="row m-3">
<input type="submit" name="enviar" value="Enviar" class="btn btn-primary btn-block">
</div>
</form>
<script src="js2/popper.min.js" type="text/javascript"></script>
<script src="js2/utilidades.js" type="text/javascript"></script>
</div>
</div>
</div>
</body>
</html>
Add this CSS.
.full-width {
width: 100vw;
position: relative;
left: 50%; /* adds left 50% to the element */
right: 50%; /* adds right 50% to the element */
margin-left: -50vw; /* it works as left: 0 */
margin-right: -50vw; /* it works as right: 0 */
}
add another div with class = "container" before form. it will work

Extra white space is showing at the bottom of my card title using Bootstrap 4

I am new to PHP and bootstrap. I am making a login form which was perfectly fine when I do not put <link rel="stylesheet" type="text/css" href="styles.css"> in my header.
But I can't just remove them from my header because I will need them at a later time because of some custom buttons, etc.
Take a look at this snippet below. As you can see, there is a white space when I already indicated the mt-5. Any idea what caused this and how to resolve this? Thanks in advance!
[![enter image description here][1]][1]
.index-banner {
background: linear-gradient(rgba(0, 0, 50, 0.5), rgba(0, 0, 40, 0.5)), url(images/1.jpg) no-repeat center center fixed;
background-size: cover;
}
.primary-container {
padding-top: 150px;
padding-left: 50px;
transition: all 4s ease-in-out;
line-height: 10px;
}
<?php require_once 'indexheader.php'; ?>
<!DOCTYPE html>
<html>
<head>
<title>Leafnote | Register</title>
<link rel="stylesheet" type="text/css" href="styles.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-lg-4 m-auto">
<div class="card bg-white mt-5">
<div class="card-title text-black">
<h5 class="text-center py-2 font-weight-bold">Register</h5>
</div>
<div class="card-body">
<form action="process.php" method="POST">
<input type="text" name="lname" placeholder="Lastname" class="form-control mb-2">
<input type="text" name="fname" placeholder="Firstname" class="form-control mb-2">
<input type="text" name="email" placeholder="Email address" class="form-control mb-2">
<input type="text" name="passw" placeholder="Password" class="form-control mb-2">
<input type="text" name="passw2" placeholder="Re-enter password" class="form-control mb-2">
<button class="btn btn-success btn-block mt-3" name="register" class="pt-3">Register</button>
<div class="text-center mt-3" style="font-size: 14px;">Already have an account?
Login
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
Bootstrap Provide utilities classes which will be realy handy and reduce you extra css like adding padding or margin and many more..
where ever if you need to add or remove margin you can add class, same way you can work with padding
mb-0 , mb-10
You can get more info
Bootstrap Utilities
The whitespace is actually coming from a margin-bottom in your card-title class and padding from your card-body class which is defaultly available in bootstrap cards. Simply add this to your css file to overwrite the bootstrap css
.card-title {
margin-bottom: 0 !important;
}
.card-body {
padding-top: 0 !important;
}
Add this to your stylesheet i.e. style.css
.card-body{
padding: 0 24px;
}
.card-title{
margin:0
}
No need of extra css as there are Bootstrap4 classes to remove your extra padding and margin. You can use mb-0 to remove your margin-bottom. You can learn more about Spacing in Bootstrap 4
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.1.0/css/all.css" integrity="sha384-lKuwvrZot6UHsBSfcMvOkWwlCMgc0TaWr+30HWe3a4ltaBwTZhyTEggF5tJv8tbt" crossorigin="anonymous">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-lg-4 m-auto">
<div class="card bg-white mt-5">
<div class="card-title text-black mb-0">
<h5 class="text-center py-2 font-weight-bold mb-0">Register</h5>
</div>
<div class="card-body">
<form action="process.php" method="POST">
<input type="text" name="lname" placeholder="Lastname" class="form-control mb-2">
<input type="text" name="fname" placeholder="Firstname" class="form-control mb-2">
<input type="text" name="email" placeholder="Email address" class="form-control mb-2">
<input type="text" name="passw" placeholder="Password" class="form-control mb-2">
<input type="text" name="passw2" placeholder="Re-enter password" class="form-control mb-2">
<button class="btn btn-success btn-block mt-3" name="register" class="pt-3">Register</button>
<div class="text-center mt-3" style="font-size: 14px;">Already have an account?
Login
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</body>
</html>

CSS wont load after refresh on my register(signup) form in PHP

I'm learning PHP and I found useful tutorials online, so I'm trying to build my very first site in PHP. I have a problem with CSS implementation. I keep my tab with localhost always on so I dont have to run it every single time when I change something. Problem is, when I code some CSS it loads on my registration form, but when i refresh the page, it's like I never coded CSS for that page. (sorry for bad english I hope You guys understand what I wanted to say..)
Here's the signup.php code :
<div class="container">
<div class="row" style="text-align:center;">
<h3>EPO - Sistem - Registracija </h3>
</div>
<div class="row sub_msg">
<p> Veb aplikacija za evidenciju predispitnih obaveza. </p>
</div>
<div class="row signup">
<div class="row">
<h3> Dobrodosli, molimo Vas, unesite podatke za registraciju. </h3>
</div>
<form action="" method="post" class="form-horizontal">
<div class="row form-group input_group">
<label for="" class="col-sm-2" >E-mail:</label>
<div class="col-sm-10">
<input type="text" name="email" class="form-control">
</div>
</div>
<div class="row form-group input_group">
<label for="" class="col-sm-2" >Firstname:</label>
<div class="col-sm-10">
<input type="text" name="firstname" id="firstname" class="form-control">
</div>
</div>
<div class="row form-group input_group">
<label for="" class="col-sm-2" >Lastname:</label>
<div class="col-sm-10">
<input type="text" name="lastname" id="lastname" class="form-control">
</div>
</div>
<div class="row form-group input_group">
<label for="" class="col-sm-2" >Password:</label>
<div class="col-sm-10">
<input type="password" name="password" id="password" class="form-control">
</div>
</div>
<div class="row form-group" style="margin:0px 10px 20px 10px">
<div class="col-xs-12">
<input type="submit" name="submit" id="Registruj se" class="form-control">
</div>
</div>
</form>
</div>
</div>
And here's the Index page:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>EPO - Pocetna stranica</title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<link rel="stylesheet" href=" ./css/custom.css">
</head>
<body>
<nav class="navbar" style="background-color: #c40707">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand crud" style="color: darkgray !important" href="#">EPO Aplikacija</a>
</div>
</div>
</nav>
<div class="container">
<ul class="nav nav-tabs">
<li><a data-toggle='tab' href="#index">Pocetna stranica</a></li>
<li><a data-toggle='tab' href="#login">Ulogujte se</a></li>
<li><a data-toggle='tab' href="#signup">Prijavite se</a></li>
</ul>
<div class="tab-content">
<div id="index" class="tab-pane fade in">
<p>Index</p>
</div>
<div id="login" class="tab-pane fade in">
<p>Login</p>
</div>
<div id="signup" class="tab-pane fade in">
<?php include("./user/signup.php"); ?>
</div>
</div>
</div>
</body>
</html>
And here's the css code:
body{
background-color: darkgray;
font-size: 22px;
margin: 0;
padding: 0;
}
.crud{
width:auto;
color: #605d5d !important;
font-size: 25px;
font-weight: 800;
}
.sub_msg{
text-align: center;
padding: 10px 0px 20px 0px;
}
.signup{
border: 1px solid #c40707;
text-align: center;
width: 60%;
height: auto;
margin: auto;
}
.input_group{
margin: 0px 20px 20px 20px;
}
.input_group input{
height: 40px;
font-size: 20px;
}
input[type="submit"]{
height: 40px;
font-size: 20px;
font-weight: bold;
background-color: #c40707;
color: #605d5d !important;
}
I'm stuck her for over two hours, and I'm pretty sure it's some beginners silly mistake but I can't find it..
Correct the path of from <link rel="stylesheet" href=" ./css/custom.css"> to <link rel="stylesheet" href="./css/custom.css">
If still not work then force your browser to refresh the stylesheet.
Check by adding version number like
<link rel="stylesheet" type="text/css" href="./css/custom.css?version=51">
In the code below href attribute has unneeded space in it.
<link rel="stylesheet" href=" ./css/custom.css">
Should be:
<link rel="stylesheet" href="./css/custom.css">
Also sometimes you may need to clear cache for the changes in your css to appear.
In this case, cause it can become tiresome pressing the refresh button, rather than do a refresh, I add a random value at the end of the css url to make it appear like a new url so no caching will happen.
Like
<link rel="stylesheet" href="./css/custom.css?<?php echo rand(1,300);?>">
Try to change this line (assuming that your css folder in in the same level as you index.php)
<link rel="stylesheet" href=" ./css/custom.css">
To this this
<link rel="stylesheet" href="css/custom.css?t=<?php echo time(); ?>">
Remove the <?php echo time(); ?> once you go on production as it meant on for development so you don't need to clear the cache or the hard reload if the changes in your css are not reflected in the browser.

PHP: $_GET not working/ nothing being displayed on page

I have been working on a simple website for a while, trying to learn PHP. I have made a simple php form, using bootstrap.
I use the GET method to get the text from the input into the url, and it shows up on the search.php url shown here:
URL
File Structure:
Screenshot of directories
For some reason, when i try to echo the value on the search.php page, the web page is blank. I have probably made a stupid error, so any help would be great!
index.php code:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Mc Report</title>
<meta name="description" content="Mc Report">
<meta name="author" content="Cre8tionz">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<link rel="stylesheet" href="css/styles.css">
<link rel="stylesheet" href="css/bootstrap.css">
<link rel="stylesheet" href="css/bootstrap-theme.css">
<script>
$(function(){
$(".dropdown-menu li a").click(function(){
$(".but:first-child").text($(this).text());
$(".but:first-child").val($(this).text());
});
});
</script>
</head>
<body>
<div class="container container-table">
<div class="row vertical-center-row">
<div class="text-center col-lg-8 col-lg-offset-2">
<div class="main-logo">
<img src="img/logo.png"></img>
</div>
<div class="row">
**<form action="search.php" method="get" novalidate="novalidate">
<div class="col-lg-10">
<div class="input-group">
<input name="q" type="search" class="form-control" aria-label="..." placeholder="Search for a username">
<div class="input-group-btn">
<button type="button" class="but btn btn-default dropdown-toggle pull-right" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Catageory<span class="caret"></span></button>
<ul class="dropdown-menu dropdown-menu-right">
<li>Mc-Market Username</li>
<li>Minecraft Username</li>
<li>Minecraft UUID</li>
</ul>
</div>
</div>
</div>
<div class="col-lg-2">
<div class="btn-group" role="group" aria-label="...">
<button type="submit" class="btn btn-default">Search</button>
</div>
</div>
</form>**
</div>
</div>
<footer>
<div class="footer">
<div class="container narrow row-fluid text-center navbar-fixed-bottom">
<div class="col-lg-4">
Mc Report
</div>
<div class="col-lg-4">
About
</div>
<div class="col-lg-4">
Copyright © 2016
</div>
</div>
</div>
</footer>
</div>
</div>
</body>
</html>
search.php code:
<html>
<body>
<?php
if( $_GET["q"] ) {
print_r($_GET);
$searchquery = $_GET["q"];
echo $searchquery;
}
?>
</html>
</body>
Your URL is file:///...
Most likely you are opening your local files in a browser. The browser cannot execute PHP scripts, so it considers the whole PHP code between < and > as a long unknown tag. Tags are not displayed, so you see a blank page.
You need a webserver to execute PHP scripts.
The most simple way to run a webserver is to run php -S localhost:8001 in your project root (mcreport.net directory).
Then open http://localhost:8001/ in your browser.

Categories