Skip to content

Commit 83575ae

Browse files
committed
initial commit
initial commit
1 parent fda145f commit 83575ae

File tree

135 files changed

+54140
-0
lines changed

Some content is hidden

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

135 files changed

+54140
-0
lines changed

.htaccess

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
RewriteEngine On
2+
3+
RewriteRule ^register/?$ register.php
4+
5+
RewriteRule ^forgotpassword/?$ forgot.php
6+
7+
RewriteRule ^activate/([0-9a-zA-Z-\s]+)/?$ activate1.php?idi=$1 [QSA,L]
8+
9+

activate1.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
2+
<?php
3+
4+
include 'includes/autoloader.inc.php';
5+
include 'functions.php';
6+
7+
$users = new Users;
8+
9+
$errormsg = "";
10+
$infomesg = "";
11+
12+
13+
14+
if(isset($_GET['idi'])) {
15+
16+
17+
$token = cleaninput($_GET['idi']);
18+
$response = $users->activate($token);
19+
20+
if($response == true){
21+
22+
$_SESSION['messeage_d'] = "Account Successfully Verified";
23+
header('location:'.baseurl());
24+
exit();
25+
}
26+
else
27+
{
28+
$_SESSION['messeage_d'] = "Invalid Activation Link.";
29+
header('location:'.baseurl());
30+
exit();
31+
32+
}
33+
34+
}
35+
36+
header('location:'.baseurl());
37+
exit();
38+
39+
?>

classes/dbh.class.php

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?php
2+
3+
4+
5+
class Dbh{
6+
7+
private $servername;
8+
private $username;
9+
private $password;
10+
private $dbname;
11+
protected $db;
12+
13+
14+
protected function connect(){
15+
16+
17+
$this->servername = "localhost";
18+
$this->username = "root";
19+
$this->password = "";
20+
$this->dbname = "oop";
21+
22+
/*******MYsqli way*********/
23+
24+
/*$conn = new mysqli($this->servername, $this->username, $this->password, $this->dbname);
25+
26+
return $conn;*/
27+
28+
29+
/***********PDO**************/
30+
31+
32+
try {
33+
34+
$dsn = "mysql:host=".$this->servername.";dbname=".$this->dbname.";port:3308";
35+
$conn = new PDO($dsn, $this->username, $this->password);
36+
// set the PDO error mode to exception
37+
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
38+
return $conn;
39+
}
40+
catch(PDOException $e)
41+
{
42+
echo "Connection failed: " . $e->getMessage();
43+
}
44+
45+
46+
/*$dsn = "mysql:host=".$this->servername.";dbname=".$this->dbname.";port:3308";
47+
$conn = new PDO($dsn, $this->username, $this->password);
48+
$conn->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
49+
return $conn;*/
50+
51+
52+
53+
54+
}
55+
56+
57+
58+
}
59+
60+
61+
62+
63+
64+
65+
66+
67+
?>

classes/mailer.class.php

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
/**
3+
* Mail Class
4+
*/
5+
6+
class Mailer
7+
{
8+
public $sendTo;
9+
public $subject;
10+
public $message;
11+
public $headers;
12+
public $error = [];
13+
14+
public function __construct($sendTo, $subject, $message)
15+
{
16+
$this->sendTo = $sendTo;
17+
$this->subject = $subject;
18+
$this->message = $message;
19+
$this->headers = $this->setHeader();
20+
}
21+
22+
public function setHeader() {
23+
24+
$headers = "From: huzztech <[email protected]> \r\n";
25+
$headers .= "Reply-To: [email protected] \r\n";
26+
$headers .= "MIME-Version: 1.0\r\n";
27+
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
28+
29+
$this->headers = $headers;
30+
return $this;
31+
}
32+
33+
public function send() {
34+
35+
$to = $this->sendTo;
36+
$subject = $this->subject;
37+
$message = $this->message;
38+
$headers = $this->headers;
39+
40+
return mail($to, $subject, $message, $headers);
41+
}
42+
}

classes/users.class.php

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
<?php
2+
3+
4+
class Users extends Dbh{
5+
6+
7+
public $table = 'signup';
8+
public $pk = 'user_id';
9+
public $oby = "";
10+
public $tabrows = 0;
11+
12+
public $id = '';
13+
public $name = '';
14+
public $email = '';
15+
public $password = '';
16+
public $dob = '';
17+
public $status = '';
18+
public $company_id = '';
19+
public $user_type = '';
20+
public $master = '';
21+
public $verifyToken = '';
22+
public $remember_token = '';
23+
public $created_at = '';
24+
public $updated_at = '';
25+
26+
public $Query;
27+
28+
29+
function setvalues($name, $email, $password, $dob){
30+
31+
$this->name = $name;
32+
$this->email = $email;
33+
$this->password = $password;
34+
$this->dob = $dob;
35+
}
36+
37+
public function FetchAll(){
38+
return $this->Query->fetchAll(PDO::FETCH_OBJ);
39+
}
40+
41+
/*
42+
* fetch single row from specific table
43+
*/
44+
45+
public function Single(){
46+
return $this->Query->fetch(PDO::FETCH_OBJ);
47+
}
48+
49+
50+
public function Query($query, $param = []){
51+
if(empty($param)){
52+
/*
53+
* if we dont have the parameters
54+
*/
55+
$this->Query = $this->connect()->prepare($query);
56+
return $this->Query->execute();
57+
} else {
58+
/*
59+
* if we have some parameters
60+
*/
61+
62+
$this->Query = $this->connect()->prepare($query);
63+
return $this->Query->execute($param);
64+
}
65+
66+
}
67+
68+
69+
public function CountRows(){
70+
return $this->Query->rowCount();
71+
}
72+
73+
74+
75+
function insert(){
76+
77+
$name = $this->name;
78+
$email = $this->email;
79+
$password = encryptdata($this->password);
80+
$dob = $this->dob;
81+
$verifyToken = random_string(50);
82+
83+
$sql = "INSERT INTO users (name,email,password,dob,verifyToken) VALUES (?,?,?,?,?)";
84+
$results = $this->connect()->prepare($sql);
85+
return $results->execute([$name, $email, $password, $dob, $verifyToken]);
86+
87+
}
88+
89+
90+
91+
function activate($token) {
92+
93+
94+
$this->Query("SELECT * FROM users WHERE verifyToken = ?", [$token]);
95+
96+
$counter = $this->CountRows();
97+
98+
if($counter > 0) {
99+
100+
$sql = "UPDATE users
101+
SET
102+
status = 1,
103+
verifyToken = ''
104+
105+
WHERE verifyToken = ?";
106+
107+
$results = $this->connect()->prepare($sql);
108+
109+
$results->execute([$token]);
110+
111+
return 1;
112+
113+
}
114+
else
115+
{
116+
return 0;
117+
}
118+
}
119+
120+
121+
122+
}
123+
124+
125+
?>

db/oop.sql

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
-- phpMyAdmin SQL Dump
2+
-- version 4.9.2
3+
-- https://www.phpmyadmin.net/
4+
--
5+
-- Host: 127.0.0.1:3306
6+
-- Generation Time: Feb 27, 2020 at 05:24 PM
7+
-- Server version: 10.4.10-MariaDB
8+
-- PHP Version: 7.3.12
9+
10+
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
11+
SET AUTOCOMMIT = 0;
12+
START TRANSACTION;
13+
SET time_zone = "+00:00";
14+
15+
16+
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
17+
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
18+
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
19+
/*!40101 SET NAMES utf8mb4 */;
20+
21+
--
22+
-- Database: `oop`
23+
--
24+
25+
-- --------------------------------------------------------
26+
27+
--
28+
-- Table structure for table `users`
29+
--
30+
31+
DROP TABLE IF EXISTS `users`;
32+
CREATE TABLE IF NOT EXISTS `users` (
33+
`id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
34+
`name` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
35+
`email` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
36+
`password` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
37+
`dob` date DEFAULT NULL,
38+
`status` tinyint(1) NOT NULL DEFAULT 0,
39+
`company_id` int(11) NOT NULL DEFAULT 0,
40+
`user_type` varchar(255) CHARACTER SET utf8 NOT NULL DEFAULT 'user',
41+
`master` varchar(255) CHARACTER SET utf8 NOT NULL DEFAULT '0',
42+
`verifyToken` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
43+
`remember_token` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
44+
`created_at` timestamp NULL DEFAULT NULL,
45+
`updated_at` timestamp NULL DEFAULT NULL,
46+
PRIMARY KEY (`id`),
47+
UNIQUE KEY `users_email_unique` (`email`)
48+
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
49+
50+
--
51+
-- Dumping data for table `users`
52+
--
53+
54+
INSERT INTO `users` (`id`, `name`, `email`, `password`, `dob`, `status`, `company_id`, `user_type`, `master`, `verifyToken`, `remember_token`, `created_at`, `updated_at`) VALUES
55+
(1, 'HuzzTech', '[email protected]', '$2y$10$c1nBZ0lW2QY4cW3InCg7BeEXwniFLU4Tnbe1kVY5g8QHINnZjQ0/u', '2020-12-31', 1, 0, 'user', '0', '', NULL, '2020-02-14 00:50:28', '2020-02-14 00:51:11');
56+
COMMIT;
57+
58+
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
59+
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
60+
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

0 commit comments

Comments
 (0)