Skip to content

Commit c6f4e9a

Browse files
author
akarim
committed
edit readme file
1 parent 9297940 commit c6f4e9a

File tree

363 files changed

+161149
-6
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

363 files changed

+161149
-6
lines changed

MPT/images/new_srm.gif

680 KB
Loading

MPT/images/signup.png

77.7 KB
Loading

MPT/images/wizard.png

33.8 KB
Loading

MPT/index.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?php
2+
header('location: wizard/setconfig.php');

MPT/shared/bll/index.php

Whitespace-only changes.

MPT/shared/bll/mail.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
if (! defined('DIRECTACESS')) exit('No direct script access allowed');
3+
class mail
4+
{
5+
6+
public function __construct()
7+
{
8+
9+
10+
11+
}
12+
13+
public function send($to, $from, $subject, $message)
14+
{
15+
$message = '<html lang="en">
16+
<head>
17+
<meta charset="UTF-8">
18+
<title>Pivot-table</title>
19+
</head>
20+
<body style="margin:0px;color: #000;direction: ltr;font-family: "Lobster", Georgia, Times, serif;letter-spacing: 1px;">
21+
'.$message.'
22+
</body>
23+
</html>';
24+
25+
$header = "From: $from\n";
26+
$header .= "MIME-Version: 1.0\n";
27+
$header .= "Content-type: text/html; charset=iso-8859-1\n";
28+
29+
$mail_sent = @mail($to, $subject, $message, $header);
30+
31+
if($mail_sent) return true;
32+
else return false;
33+
}
34+
35+
}
36+
?>

MPT/shared/cl_login.php

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
<?php
2+
3+
/*
4+
this class to handle login confirmation and login status
5+
*/
6+
if (! defined('DIRECTACESS')) exit('No direct script access allowed');
7+
if (file_exists(dirname(__FILE__) . DIRECTORY_SEPARATOR . "security.php"))
8+
require_once "security.php";
9+
class Login {
10+
11+
private $username, $email, $password, $securityFullPath;
12+
13+
public function __construct() {
14+
/*
15+
Make user logged out after 1 hour if no action was presented.
16+
*/
17+
$this->securityFullPath = dirname(__FILE__) . DIRECTORY_SEPARATOR . "security.php";
18+
if (file_exists($this->securityFullPath)) {
19+
20+
global $email, $username, $password;
21+
$this->email = $email;
22+
$this->username = $username;
23+
$this->password = $password;
24+
}
25+
}
26+
27+
/*
28+
Check if user have logged in or not, RETURN true || false
29+
*/
30+
31+
public function is_loggedin() {
32+
if (file_exists($this->securityFullPath)) {
33+
34+
35+
if (isset($_SESSION['PT_Login_username']) && isset($_SESSION['PT_Login_password'])) {
36+
$session_username = $_SESSION['PT_Login_username'];
37+
$session_password = $_SESSION['PT_Login_password'];
38+
39+
if ($session_username == $this->username && $session_password == $this->password . md5($_SERVER['HTTP_USER_AGENT']) && $_SESSION['PT_Login_validLogin'] == sha1("PT_1701 logged in").md5($_SERVER['HTTP_USER_AGENT']))
40+
return true;
41+
else
42+
return false;
43+
} else {
44+
return false;
45+
}
46+
} else {
47+
return false;
48+
}
49+
}
50+
51+
/*
52+
this function to handle redirect in action if is user logged in true or false.
53+
AND this function it must recently used ..
54+
params:
55+
isLoggedin: set to false if you want to redirect user to [PARAM: location] if not logged in (default: login.php)
56+
else set to true if you want to redirect user to [PARAM: location] if logged in
57+
location: ..
58+
*/
59+
60+
public function headerTo($isLoggedin = false, $location = "login.php") {
61+
if ($this->is_loggedin() === $isLoggedin)
62+
header("location: {$location}");
63+
}
64+
65+
/*
66+
this function to confirm login process
67+
params: USER INPUTS [POST] username, password
68+
*/
69+
70+
public function confirm($username, $password) {
71+
72+
if (!file_exists($this->securityFullPath)) { // check if security.php file is not exists so User must Sign up first
73+
return 'do_not_have_account';
74+
} else {
75+
// User inputs: $username, $password
76+
$salt = createSalt($username);
77+
$md5_password = hash("sha256", $password . $salt);
78+
79+
// validation:: check if username and password valid formats
80+
if ((preg_match('/[^a-z0-9_]/i', $username) || strlen($username) < 5 || is_numeric($username[0]) || $username[0] == '_') || (preg_match('/[ \/\\\]/i', $password) || strlen($password) < 8 || !preg_match('/[a-z]+/', $password) || !preg_match('/[A-Z]+/', $password) || !preg_match('/[0-9]+/', $password) ))
81+
return 'wrong_usernamewrong_password';
82+
/* else if(preg_match('/[^a-z0-9_]/i', $username) || strlen($username) < 5 || is_numeric($username[0]) || $username[0] === '_')
83+
return 'wrong_username';
84+
else if(preg_match('/[ \/\\\]/i', $password) || strlen($password) < 8 || !preg_match('/[a-z]+/', $password) || !preg_match('/[A-Z]+/', $password) || !preg_match('/[0-9]+/', $password))
85+
return 'wrong_password'; */
86+
else {
87+
// if username and password is valid then check if username and password correct
88+
if ($username != $this->getUsername() || $md5_password != $this->getPassword()) {
89+
return 'wrong_usernamewrong_password';
90+
// else if($username !== $this->getUsername())
91+
// return 'wrong_username';
92+
// else if($md5_password !== $this->getPassword())
93+
// return 'wrong_password';
94+
} else {
95+
// if username and password correct then set Login Session
96+
$_SESSION['PT_Login_username'] = $username;
97+
$_SESSION['PT_Login_password'] = $md5_password.md5($_SERVER['HTTP_USER_AGENT']);
98+
$_SESSION['PT_Login_validLogin'] = sha1("PT_1701 logged in").md5($_SERVER['HTTP_USER_AGENT']);
99+
100+
return 'done';
101+
}
102+
}
103+
}
104+
}
105+
106+
/*
107+
to get username out side this class
108+
*/
109+
110+
public function getUsername() {
111+
return $this->username;
112+
}
113+
114+
/*
115+
to get password out side this class
116+
*/
117+
118+
public function getPassword() {
119+
return $this->password;
120+
}
121+
122+
/*
123+
to get email out side this class
124+
*/
125+
126+
public function getEmail() {
127+
return $this->email;
128+
}
129+
130+
}
131+
132+
?>

MPT/shared/cl_navbar.php

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
<?php
2+
/*
3+
this class will handle navbar status [Login || Not Login] and use print_navbar() to print correct navbar
4+
*/
5+
if (! defined('DIRECTACESS')) exit('No direct script access allowed');
6+
class Navbar
7+
{
8+
private $login;
9+
10+
public function __construct() {
11+
global $login;
12+
$this->login = $login;
13+
}
14+
15+
/*
16+
this function to print navbar
17+
params:
18+
tableName: will be basename(__DIR__) if used from generated tables else (for wizard) false
19+
20+
*/
21+
public function print_navbar($tableName = false)
22+
{
23+
if($tableName === false) {
24+
echo // echo navbar and logo [for wizard]
25+
'<div class="container" id="cal">
26+
<div class="header">
27+
<img id="logo-cs" src="../tables/common/img/app-logo.png" alt="app-logo" />
28+
</div>
29+
</div>
30+
<nav class="navbar navbar-default navbar-static-top" role="navigation">
31+
<div class="container-fluid">
32+
33+
<!-- Brand and toggle get grouped for better mobile display -->
34+
<div class="navbar-header" style="position: relative;z-index: 100000;">
35+
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar-collapse">
36+
<span class="sr-only">Toggle navigation</span>
37+
<span class="icon-bar"></span>
38+
<span class="icon-bar"></span>
39+
<span class="icon-bar"></span>
40+
</button>
41+
</div>
42+
43+
<!-- Collect the nav links, forms, and other content for toggling -->
44+
<div class="collapse navbar-collapse" id="navbar-collapse">
45+
<ul class="nav navbar-nav navbar-right" style="margin-right: 20px;">
46+
<li><a href="#">Welcome <strong>'. $this->login->getUsername() .'</strong></a></li>
47+
<li><a href="logout.php">Logout</a></li>
48+
</ul>
49+
</div><!-- .navbar-collapse -->
50+
</div><!-- .container-fluid -->
51+
</nav>';
52+
} else { // echo just navbar [for generated tables]
53+
$navbarBtns = "";
54+
if($this->login->is_loggedin()) {
55+
$navbarBtns =
56+
'<ul class="nav navbar-nav">
57+
<li><a href="../../wizard/setconfig.php" style="font-size: 14px;font-weight: 700;"><span class="glyphicon glyphicon-folder-open"></span>&nbsp;&nbsp;Manage tables</a></li>
58+
<li><a href="#" id="php-to-excel" onclick="return false;" style="font-size: 14px;font-weight: 700;"><img src="../common/img/excel-icon.png" width="22" height="22" /> <span style="display: inline-block;position: relative; bottom: 7px;">Export to excel</span></a></li>
59+
</ul>
60+
<ul class="nav navbar-nav navbar-right" style="margin-right: 20px;">
61+
<li><a href="#" style="font-size: 14px;">Welcome <strong>'. $this->login->getUsername() .'</strong></a></li>
62+
<li><a href="../../wizard/logout.php" style="font-size: 14px;">Logout</a></li>
63+
</ul>';
64+
} else {
65+
$navbarBtns =
66+
'<ul class="nav navbar-nav">
67+
<li><a href="#" id="php-to-excel" onclick="return false;" style="font-size: 14px;font-weight: 700;"><img src="../common/img/excel-icon.png" width="22" height="22" /> <span style="display: inline-block;position: relative; bottom: 7px;">Export to excel</span></a></li>
68+
</ul>
69+
<ul class="nav navbar-nav navbar-right" style="margin-right: 20px;">
70+
<li><a href="../../wizard/login.php?from=table&path='. $tableName .'">Login</a></li>
71+
<!-- <li><a href="../../wizard/signup.php">Signup</a></li> -->
72+
</ul>';
73+
}
74+
echo
75+
'<nav class="navbar navbar-default navbar-static-top" role="navigation">
76+
<div class="container-fluid">
77+
<!-- Brand and toggle get grouped for better mobile display -->
78+
<div class="navbar-header">
79+
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar-collapse">
80+
<span class="sr-only">Toggle navigation</span>
81+
<span class="icon-bar"></span>
82+
<span class="icon-bar"></span>
83+
<span class="icon-bar"></span>
84+
</button>
85+
</div>
86+
87+
<!-- Collect the nav links, forms, and other content for toggling -->
88+
<div class="collapse navbar-collapse" id="navbar-collapse">
89+
'. $navbarBtns .'
90+
</div><!-- /.navbar-collapse -->
91+
</div><!-- /.container-fluid -->
92+
</nav>';
93+
}
94+
}
95+
}
96+
$navbar = new Navbar();

0 commit comments

Comments
 (0)