diff --git a/controllers/addComments.php b/controllers/addComments.php index 8f93c39..a74541b 100644 --- a/controllers/addComments.php +++ b/controllers/addComments.php @@ -11,7 +11,7 @@ ?> \ No newline at end of file diff --git a/controllers/member.php b/controllers/member.php index 92dd57a..495b28b 100644 --- a/controllers/member.php +++ b/controllers/member.php @@ -1,7 +1,4 @@ get_values(); - var_dump($_SESSION["user"]); header("Location: ../views/profilePage.php?username=".$username); } else diff --git a/controllers/signup.php b/controllers/signup.php index f518764..6a4a608 100644 --- a/controllers/signup.php +++ b/controllers/signup.php @@ -14,7 +14,7 @@ } elseif($pass!=$cpass) { - $error = "cannot leave any field empty!"; + $error = "Passwords do not match!"; } else { diff --git a/controllers/upload.php b/controllers/upload.php index ee98237..5cb7f6e 100644 --- a/controllers/upload.php +++ b/controllers/upload.php @@ -1,7 +1,4 @@ close(); return $rs; } else{ - - echo $conn->error; + $conn->close(); return false; } - $conn->close(); - return false; } public static function insertQuery($sql){ @@ -54,7 +52,7 @@ class DataAccessHelper { private static function getConnection(){ $servername = "localhost"; $username = "root"; - $password = ""; + $password = "Admin@1234"; $dbname = "photoshare"; $conn = new mysqli($servername, $username, $password, $dbname); diff --git a/models/album.php b/models/album.php index 6503b57..245ca30 100644 --- a/models/album.php +++ b/models/album.php @@ -30,8 +30,10 @@ class album{ $query="select * from albumdata where albumId=$albumId"; $result=DataAccessHelper::executeQuery($query); $result2=array(); - foreach($result as $i){ - $result2[$i]=$result[$i]['imgId']; + if($result){ + foreach($result as $row){ + $result2[]=$row['imgId']; + } } return $result2; } diff --git a/models/group.php b/models/group.php index 657bf55..ce971f3 100644 --- a/models/group.php +++ b/models/group.php @@ -5,33 +5,33 @@ require_once("../models/DataAccessHelper.php"); class group{ public static function insertGroup($name){ - $query ="insert into groups(gname) values('$name')"; - $result=DataAccessHelper::insertQuery($query); - if($result===TRUE) - { - return true; + $query ="insert into `groups`(gname) values('$name')"; + $groupId=DataAccessHelper::insertQuerySpecial($query); + if($groupId){ + return $groupId; } return false; } - - public static function insertMember($name,$username) + + public static function insertMember($groupId,$username) { - $query ="insert into members(gname,username) values('$name','$username')"; + $query ="insert into members(groupId,username) values('$groupId','$username')"; $result=DataAccessHelper::insertQuery($query); if($result===TRUE){ return true; } return false; } - + public static function getAllUserGroups($username) { - $query="select * from groups join members on members.gname= groups.gname where members.username= '$username'"; + $query="select * from `groups` join members on members.groupId= `groups`.groupId where members.username= '$username'"; $result=DataAccessHelper::executeQuery($query); return $result; } + public static function getAllUsers($groupId){ - $query="select * from members join groups on members.gname=groups.gname where groupId= $groupId"; + $query="select * from members join `groups` on members.groupId=`groups`.groupId where `groups`.groupId= $groupId"; $result=DataAccessHelper::executeQuery($query); return $result; } diff --git a/models/photo.php b/models/photo.php index dbaa830..5c6d952 100644 --- a/models/photo.php +++ b/models/photo.php @@ -9,16 +9,16 @@ public static function getImage($id){ $query="select * from photos where imgId='".$id."'"; $rs = DataAccessHelper::executeQuery($query); - if (sizeof($rs) > 0){ + if ($rs && sizeof($rs) > 0){ return $rs; } return false; } - + public static function getComments($imgId){ $query='select fullname,commentstr from imgcomments join users on users.username=imgcomments.username where imgId="'.$imgId.'"'; $rs = DataAccessHelper::executeQuery($query); - if (sizeof($rs) > 0){ + if ($rs && sizeof($rs) > 0){ return $rs; } return false; @@ -36,16 +36,16 @@ public static function getImageusername($username){ $query="select * from photos where username='".$username."'"; $rs = DataAccessHelper::executeQuery($query); - if ($rs > 0){ + if ($rs && sizeof($rs) > 0){ return $rs; } return false; } - + public static function getImagePublic(){ $query='select * from photos where shareStatus=1'; $rs = DataAccessHelper::executeQuery($query); - if ($rs > 0) + if ($rs && sizeof($rs) > 0) { return $rs; } @@ -56,14 +56,15 @@ public static function getShared($username){ $query='select * from sharedto join photos on photos.imgId=sharedto.imgId and sharedto.username="'.$username.'"'; $rs = DataAccessHelper::executeQuery($query); - if (sizeof($rs) > 0){ + if ($rs && sizeof($rs) > 0){ return $rs; } return false; } public static function insertImage($image,$name,$description,$access,$username,$label, $albumId){ - $query="insert into photos (name,imageFile,shareStatus,description,username,label, albumId)values('$name','$image','$access','$description','$username','$label','$albumId')"; + $albumIdSql = ($albumId === null) ? 'NULL' : "'$albumId'"; + $query="insert into photos (name,imageFile,shareStatus,description,username,label, albumId)values('$name','$image','$access','$description','$username','$label',$albumIdSql)"; $rs = DataAccessHelper::insertQuerySpecial($query); if($rs){ $string = $label; @@ -71,8 +72,7 @@ while ($token !== false) { - echo $rs; - $query="insert into imagetags(imgId,str) values('$rs','$token')"; + $query="insert into imagetags(imgId,tag) values('$rs','$token')"; DataAccessHelper::insertQuerySpecial($query); $token = strtok(" "); } diff --git a/models/user.php b/models/user.php index 7ad740c..ad29663 100644 --- a/models/user.php +++ b/models/user.php @@ -34,15 +34,12 @@ class User { public function get_values(){ $query = "select * from users where username='" . $this->username . "'"; $rs = DataAccessHelper::executeQuery($query); - + if (sizeof($rs) > 0){ - var_dump($rs[0]); - $tusername=$rs[0]["username"]; - $tfullname=$rs[0]["fullname"]; - $temail=$rs[0]["email"]; - } - $temp=array('username'=>$tusername,'fullname'=>$tfullname,'email'=>$temail); - return $temp; + $temp=array('username'=>$rs[0]["username"],'fullname'=>$rs[0]["fullname"],'email'=>$rs[0]["email"]); + return $temp; + } + return array('username'=>'','fullname'=>'','email'=>''); } public function echoevery(){ @@ -61,12 +58,12 @@ class User { } public static function signup($username, $fullname,$email,$password){ - $query ="insert into users(username,fullname,email,pass)"."VALUES('$username','$fullname', '$email', '$pass')"; + $query ="insert into users(username,fullname,email,pass)"."VALUES('$username','$fullname', '$email', '$password')"; $result=DataAccessHelper::insertQuery($query); if($result===TRUE){ return true; } - + return false; } } ?> \ No newline at end of file diff --git a/views/album.php b/views/album.php index dfbe7d7..1bc3f98 100644 --- a/views/album.php +++ b/views/album.php @@ -1,4 +1,4 @@ - - + PhotoShare - +
@@ -34,13 +31,12 @@

Create New Albums

-
@@ -55,4 +51,4 @@
- \ No newline at end of file + diff --git a/views/allalbums.php b/views/allalbums.php index 892ff81..ef649f2 100644 --- a/views/allalbums.php +++ b/views/allalbums.php @@ -14,20 +14,10 @@ diff --git a/views/allphotos.php b/views/allphotos.php index 4a7ca3d..5ee6ed7 100644 --- a/views/allphotos.php +++ b/views/allphotos.php @@ -57,7 +57,7 @@ document.getElementById("comments").innerHTML = xmlhttp.responseText; } }; - xmlhttp.open("GET", "../controllers/loadComments.php?imgId= '" + id +"'", true); + xmlhttp.open("GET", "../controllers/loadComments.php?imgId=" + id, true); xmlhttp.send(); } @@ -84,23 +84,9 @@ } else { - $id = 0; - $files = glob('c:/xampp/htdocs/webproject/views/images/*'); // get all file names - foreach($files as $file) - { - if(is_file($file)) - unlink($file); - } - - $paths=array(); - foreach($rs as $row) { - $paths[]="c:/xampp/htdocs/webproject/views/images/".$row['imgId'].".jpg"; - file_put_contents("c:/xampp/htdocs/webproject/views/images/".$row['imgId'].".jpg", $row['imageFile']); - - echo '<img class="col-md-3" height="190" width="195" id="'.$row['imgId'].'" src="data:image/jpg;base64,'.base64_encode( $row['imageFile']).'" onclick=\'addcomments(id)\'/>'; - $id++; + echo '<img class="col-md-3" height="190" width="195" id="'.$row['imgId'].'" src="data:image/jpg;base64,'.base64_encode( $row['imageFile']).'" onclick=\'addcomments(this.id)\'/>'; } } ?> diff --git a/views/group.php b/views/group.php index 9683a93..4377bcd 100644 --- a/views/group.php +++ b/views/group.php @@ -1,4 +1,4 @@ -<?php +<?php session_start(); if(isset($_SESSION['user'])) { @@ -7,26 +7,23 @@ else { header("Location: ../views/signinPage.php?message=".urlencode("Login again!")); + exit(); } + require_once("engine.php"); + require_once("../models/user.php"); + require_once("../controllers/group.php"); ?> <!DOCTYPE html> <html lang="en"> <head> - <?php - require_once("engine.php"); - require_once("../models/user.php"); - require_once("../controllers/group.php"); - echo $includes; - ?> + <?php echo $includes; ?> <title> PhotoShare - +
@@ -34,13 +31,12 @@

Create New Groups

-
@@ -55,4 +51,4 @@
- \ No newline at end of file + diff --git a/views/member.php b/views/member.php index 27a8c69..082c6bf 100644 --- a/views/member.php +++ b/views/member.php @@ -1,31 +1,28 @@ - - + PhotoShare - +
@@ -36,11 +33,11 @@
- +
@@ -94,4 +89,4 @@
- \ No newline at end of file + diff --git a/views/shared.php b/views/shared.php index 7fd289c..bb76145 100644 --- a/views/shared.php +++ b/views/shared.php @@ -57,7 +57,7 @@ document.getElementById("comments").innerHTML = xmlhttp.responseText; } }; - xmlhttp.open("GET", "../controllers/loadComments.php?imgId= '" + id +"'", true); + xmlhttp.open("GET", "../controllers/loadComments.php?imgId=" + id, true); xmlhttp.send(); } @@ -84,23 +84,9 @@ } else { - $id = 0; - $files = glob('c:/xampp/htdocs/webproject/views/images/*'); // get all file names - foreach($files as $file) - { - if(is_file($file)) - unlink($file); - } - - $paths=array(); - foreach($rs as $row) { - $paths[]="c:/xampp/htdocs/webproject/views/images/".$row['imgId'].".jpg"; - file_put_contents("c:/xampp/htdocs/webproject/views/images/".$row['imgId'].".jpg", $row['imageFile']); - - echo ''; - $id++; + echo ''; } } ?> diff --git a/views/signinPage.php b/views/signinPage.php index d83cbf7..f9f8356 100644 --- a/views/signinPage.php +++ b/views/signinPage.php @@ -23,26 +23,9 @@ + PhotoShare-Sign in Page - PhotoShare-Sign in Page -
@@ -51,14 +34,14 @@

- - - Join + + + Join - + PhotoShare! - + Pick your Clicks... @@ -76,102 +59,20 @@ - +

- getSessionFromRedirect(); - - //check if facebook session exists - if(isset($_SESSION['fb_token'])){ - $sess = new FacebookSession($_SESSION['fb_token']); - } - //logout - $logout = 'http://localhost/webproject/controllers/logout.php'; - - //4. if fb sess exists echo name - if(isset($sess)){ - //create request object,execute and capture response - $request = new FacebookRequest($sess, 'GET', '/me'); - // from response get graph object - $response = $request->execute(); - $graph = $response->getGraphObject(GraphUser::className()); - // use graph object methods to get user details - $name= $graph->getName(); - $image = 'https://graph.facebook.com/'.$id.'/picture?width=300'; - $email = $graph->getProperty('email'); - echo "hi $name
"; - echo "your email is $email

"; - echo "

"; - echo ""; - }else{ - //else echo login - echo 'Login with facebook'; - } - ?> -
-
-
-
+
diff --git a/views/signupPage.php b/views/signupPage.php index 6da509a..d9528ce 100644 --- a/views/signupPage.php +++ b/views/signupPage.php @@ -65,8 +65,8 @@ }); - - + + diff --git a/views/upload.php b/views/upload.php index eea7e48..fd1a1c9 100644 --- a/views/upload.php +++ b/views/upload.php @@ -1,31 +1,28 @@ - - + PhotoShare - +
@@ -37,19 +34,19 @@
- +
- +
- \ No newline at end of file +