Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
leongsheng committed Jul 14, 2023
0 parents commit 0508418
Show file tree
Hide file tree
Showing 2,115 changed files with 272,660 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"liveServer.settings.port": 5501
}
269 changes: 269 additions & 0 deletions admin_class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,269 @@
<?php
session_start();
ini_set('display_errors', 1);
Class Action {
private $db;

public function __construct() {
ob_start();
include 'conn_db.php';

$this->db = $conn;
}
function __destruct() {
$this->db->close();
ob_end_flush();
}

function login(){

extract($_POST);
$qry = $this->db->query("SELECT * FROM users where username = '".$username."' and password = '".md5($password)."' ");
if($qry->num_rows > 0){
foreach ($qry->fetch_array() as $key => $value) {
if($key != 'passwors' && !is_numeric($key))
$_SESSION['login_'.$key] = $value;
}
return 1;
}else{
return 3;
}
}
function logout(){
session_destroy();
foreach ($_SESSION as $key => $value) {
unset($_SESSION[$key]);
}
header("location:login.php");
}
function logout2(){
session_destroy();
foreach ($_SESSION as $key => $value) {
unset($_SESSION[$key]);
}
header("location:../index.php");
}

function save_user(){
extract($_POST);
$data = " name = '$name' ";
$data .= ", username = '$username' ";
if(!empty($password))
$data .= ", password = '".md5($password)."' ";
$data .= ", type = '$type' ";
$chk = $this->db->query("Select * from users where username = '$username' and id !='$id' ")->num_rows;
if($chk > 0){
return 2;
exit;
}
if(empty($id)){
$save = $this->db->query("INSERT INTO users set ".$data);
}else{
$save = $this->db->query("UPDATE users set ".$data." where id = ".$id);
}
if($save){
return 1;
}
}
function delete_user(){
extract($_POST);
$delete = $this->db->query("DELETE FROM users where id = ".$id);
if($delete)
return 1;
}
function signup(){
extract($_POST);
$data = " name = '".$firstname.' '.$lastname."' ";
$data .= ", username = '$email' ";
$data .= ", password = '".md5($password)."' ";
$chk = $this->db->query("SELECT * FROM users where username = '$email' ")->num_rows;
if($chk > 0){
return 2;
exit;
}
$save = $this->db->query("INSERT INTO users set ".$data);
if($save){
$uid = $this->db->insert_id;
$data = '';
foreach($_POST as $k => $v){
if($k =='password')
continue;
if(empty($data) && !is_numeric($k) )
$data = " $k = '$v' ";
else
$data .= ", $k = '$v' ";
}
if($_FILES['img']['tmp_name'] != ''){
$fname = strtotime(date('y-m-d H:i')).'_'.$_FILES['img']['name'];
$move = move_uploaded_file($_FILES['img']['tmp_name'],'assets/uploads/'. $fname);
$data .= ", avatar = '$fname' ";

}
$save_alumni = $this->db->query("INSERT INTO alumnus_bio set $data ");
if($data){
$aid = $this->db->insert_id;
$this->db->query("UPDATE users set alumnus_id = $aid where id = $uid ");
$login = $this->login2();
if($login)
return 1;
}
}
}
function update_account(){
extract($_POST);
$data = " name = '".$firstname.' '.$lastname."' ";
$data .= ", username = '$email' ";
if(!empty($password))
$data .= ", password = '".md5($password)."' ";
$chk = $this->db->query("SELECT * FROM users where username = '$email' and id != '{$_SESSION['login_id']}' ")->num_rows;
if($chk > 0){
return 2;
exit;
}
$save = $this->db->query("UPDATE users set $data where id = '{$_SESSION['login_id']}' ");
if($save){
$data = '';
foreach($_POST as $k => $v){
if($k =='password')
continue;
if(empty($data) && !is_numeric($k) )
$data = " $k = '$v' ";
else
$data .= ", $k = '$v' ";
}
if($_FILES['img']['tmp_name'] != ''){
$fname = strtotime(date('y-m-d H:i')).'_'.$_FILES['img']['name'];
$move = move_uploaded_file($_FILES['img']['tmp_name'],'assets/uploads/'. $fname);
$data .= ", avatar = '$fname' ";

}
$save_alumni = $this->db->query("UPDATE alumnus_bio set $data where id = '{$_SESSION['bio']['id']}' ");
if($data){
foreach ($_SESSION as $key => $value) {
unset($_SESSION[$key]);
}
$login = $this->login2();
if($login)
return 1;
}
}
}


function save_category(){
extract($_POST);
$data = " name = '$name' ";
$data .= ", description = '$description' ";
if(empty($id)){
$save = $this->db->query("INSERT INTO categories set $data");
}else{
$save = $this->db->query("UPDATE categories set $data where id = $id");
}
if($save)
return 1;
}
function delete_category(){
extract($_POST);
$delete = $this->db->query("DELETE FROM categories where id = ".$id);
if($delete){
return 1;
}
}

function save_topic(){
extract($_POST);
$data = " title = '$title' ";
$data .= ", category_ids = '".(implode(",",$category_ids))."' ";
$data .= ", content = '".htmlentities(str_replace("'","&#x2019;",$content))."' ";

if(empty($id)){
$data .= ", user_id = '{$_SESSION['id']}' ";
$save = $this->db->query("INSERT INTO topics set ".$data);
}else{
$save = $this->db->query("UPDATE topics set ".$data." where id=".$id);
}
if($save)
return 1;
}
function delete_topic(){
extract($_POST);
$delete = $this->db->query("DELETE FROM topics where id = ".$id);
if($delete){
return 1;
}
}
function save_comment(){
extract($_POST);
$data = " comment = '".htmlentities(str_replace("'","&#x2019;",$comment))."' ";

if(empty($id)){
$data .= ", topic_id = '$topic_id' ";
$data .= ", user_id = '{$_SESSION['id']}' ";
$save = $this->db->query("INSERT INTO comments set ".$data);
}else{
$save = $this->db->query("UPDATE comments set ".$data." where id=".$id);
}
if($save)
return 1;
}
function delete_comment(){
extract($_POST);
$delete = $this->db->query("DELETE FROM comments where id = ".$id);
if($delete){
return 1;
}
}
function save_reply(){
extract($_POST);
$data = " reply = '".htmlentities(str_replace("'","&#x2019;",$reply))."' ";

if(empty($id)){
$data .= ", comment_id = '$comment_id' ";
$data .= ", user_id = '{$_SESSION['id']}' ";
$save = $this->db->query("INSERT INTO replies set ".$data);
}else{
$save = $this->db->query("UPDATE replies set ".$data." where id=".$id);
}
if($save)
return 1;
}
function delete_reply(){
extract($_POST);
$delete = $this->db->query("DELETE FROM replies where id = ".$id);
if($delete){
return 1;
}
}
function search(){
extract($_POST);
$data = array();
$tag = $this->db->query("SELECT * FROM categories order by name asc");
while($row= $tag->fetch_assoc()):
$tags[$row['id']] = $row['name'];
endwhile;
$ts = $this->db->query("SELECT * FROM categories where name like '%{$keyword}%' ");
$tsearch = '';
while($row= $ts->fetch_assoc()):
$tsearch .=" or concat('[',REPLACE(t.category_ids,',','],['),']') like '%[{$row['id']}]%' ";
endwhile;
// echo "SELECT t.*,u.name FROM topics t inner join users u on u.id = t.user_id where t.title LIKE '%{$keyword}%' or content LIKE '%{$keyword}%' $tsearch order by unix_timestamp(t.date_created) desc";
$topic = $this->db->query("SELECT t.*,m.name FROM topics t inner join member m on m.id = t.user_id where t.title LIKE '%{$keyword}%' or content LIKE '%{$keyword}%' $tsearch order by unix_timestamp(t.date_created) desc");
while($row= $topic->fetch_assoc()):
$trans = get_html_translation_table(HTML_ENTITIES,ENT_QUOTES);
unset($trans["\""], $trans["<"], $trans[">"], $trans["<h2"]);
$desc = strtr(html_entity_decode($row['content']),$trans);
$row['desc']=strip_tags(str_replace(array("<li>","</li>"), array("",","), $desc));
$row['view'] = $this->db->query("SELECT * FROM forum_views where topic_id=".$row['id'])->num_rows;
$row['comments'] = $this->db->query("SELECT * FROM comments where topic_id=".$row['id'])->num_rows;
$row['replies'] = $this->db->query("SELECT * FROM replies where comment_id in (SELECT id FROM comments where topic_id=".$row['id'].")")->num_rows;
$row['tags'] = array();
foreach(explode(",",$row['category_ids']) as $cat):
$row['tags'][]= $tags[$cat];
endforeach;
$row['created'] = date('M d, Y h:i A',strtotime($row['date_created']));
$row['posted'] = ucwords($row['name']);
$data[]= $row;
endwhile;
return json_encode($data);
}
}
10 changes: 10 additions & 0 deletions admin_to_member.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
session_start();
// Store data in session variables
$_SESSION["member_login"] = true;

// Redirect user to welcome page
header("location: userpage.php");

exit;
?>
26 changes: 26 additions & 0 deletions air_drone.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Tutorial Page</title>

<!-- custom css file link-->
<link rel="stylesheet" href="assets/css/tutorial.css">
</head>

<body>
<section id="blog-container">
<div class="blogs blogpost">
<div class="post">
<img src="assets/img/robottype3.png" alt="">
<h3>Learn about Autonomouns Car Driving (Simurosot)</h3>
<br><br>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>

<a href="tutorial.html">Read Next ?</a>
</div>
</div>
</section>
</body>
</html>
Loading

0 comments on commit 0508418

Please sign in to comment.