Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .buildpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<buildpath>
<buildpathentry kind="src" path=""/>
<buildpathentry kind="con" path="org.eclipse.php.core.LANGUAGE"/>
</buildpath>
22 changes: 22 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>UC3-Team-Project</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.dltk.core.scriptbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.php.core.PHPNature</nature>
</natures>
</projectDescription>
2 changes: 2 additions & 0 deletions .settings/org.eclipse.wst.validation.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
disabled=06vendor
eclipse.preferences.version=1
33 changes: 31 additions & 2 deletions core/classes/UserManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ public static function getUserFromId($uid) {
return $stmt->fetch(PDO::FETCH_OBJ);
}

public static function image_retrieve($uid) {
$pdo = Dbh::getInstance()->dbh;
$stmt = $pdo->prepare('SELECT * FROM users WHERE user_id = ? LIMIT 1');
$stmt->execute(array($uid));
$obj = $stmt->fetch(PDO::FETCH_OBJ);
return $obj->profile_image;
}

/**
* @param $email string email of logging in user
* @param $password string password of logging in user
Expand Down Expand Up @@ -86,8 +94,8 @@ public function register($email, $name, $password) {
}

public function uploadPic($file, $user_id) {

$stmt = $this->pdo->prepare('UPDATE users SET profile_image =:file WHERE user_id=:user');
$pdo = Dbh::getInstance()->dbh;
$stmt = $pdo->prepare('UPDATE users SET profile_image =:file WHERE user_id=:user');
$stmt->bindParam(':file', $file);
$stmt->bindParam(':user', $user_id);
try {
Expand All @@ -97,6 +105,27 @@ public function uploadPic($file, $user_id) {
}

}

public static function updateUserInfo($screenname, $username, $bio,
$website, $email, $country, $user_id) {
$pdo = Dbh::getInstance()->dbh;
$stmt = $pdo->prepare('UPDATE users SET screen_name =:screenname,
username = :username, bio = :bio, website = :website,
email = :email, country = :country WHERE user_id=:user');
$stmt->bindParam(':screenname', $screenname);
$stmt->bindParam(':username', $username);
$stmt->bindParam(':bio', $bio);
$stmt->bindParam(':website', $website);
$stmt->bindParam(':email', $email);
$stmt->bindParam(':country', $country);
$stmt->bindParam(':user', $user_id);

try {
$stmt->execute();
} catch (PDOException $e) {
echo "Error: " . $e->getMessage();
}
}

}

Expand Down
27 changes: 21 additions & 6 deletions profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
if (isset($_POST['image_submit'])) {
$image = file_get_contents(addslashes($_FILES['image']['tmp_name']));
$file = base64_encode($image);
$getUserManager->uploadPic($file, $user_data->user_id);
UserManager::uploadPic($file, $user_data->user_id);
}
}

Expand All @@ -33,6 +33,17 @@ function requestFollow(idol_id, fan_id) {
idol_id: idol_id, fan_id: fan_id
});
}

function edit(element) {
var parent=$(element).parent().parent();
var placeholder=$(parent).find('.text-info').text();
//hide label
$(parent).find('label').hide();
//show input, set placeholder
var input=$(parent).find('input[type="text"]');
$(input).show();
$(input).attr('placeholder', placeholder);
}
</script>

</head>
Expand Down Expand Up @@ -83,11 +94,15 @@ class="glyphicon glyphicon-user"></span> My Account</a></li>
</div>
<div class="col-md-8 col-xs-12 col-sm-6 col-lg-8">
<div class="container">
<h2><?php echo $user_data->username; ?>
<button type="submit" name="follow" class="btn btn-default" style="margin-left: 570px">
Edit
</button>
</h2>

<H2>
<label for="name" class="control-label">
<p class="text-info"><?php echo $user_data->username; ?><i class="icon-star"></i></p>
</label>
<input type="text" class="input-medium" style="display:none;">
<a href="profileEdit.php" onclick="edit(this);" style="margin-left: 570px">Edit</a>
</H2>

<p><?php echo $user_data->bio; ?></p>

</div>
Expand Down
35 changes: 24 additions & 11 deletions profileEdit.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
require_once(__DIR__.'core/init.php');
require_once('core/init.php');

$user_id = $_SESSION['user_id'];

Expand All @@ -8,7 +8,20 @@
$user_id = $_SESSION['user_id'];
$image = file_get_contents(addslashes($_FILES["image"]["tmp_name"]));
$file=base64_encode($image);
$getUserManager->uploadPic($file,$user_id);
UserManager::uploadPic($file,$user_id);
}

if(isset($_POST["confirm"]))
{
$user_id = $_SESSION['user_id'];
$screenname = $_REQUEST["screen_name"];
$username = $_REQUEST["username"];
$bio = $_REQUEST["bio"];
$website = $_REQUEST["website"];
$email = $_REQUEST["email"];
$country = $_REQUEST["country"];
UserManager::updateUserInfo($screenname, $username, $bio,
$website, $email, $country, $user_id);
}

?>
Expand Down Expand Up @@ -74,8 +87,8 @@ class="glyphicon glyphicon-user"></span> My Account</a></li>
<br><label class="label">Profile picture</label>
<?php
$user_id = $_SESSION['user_id'];
$userimage=$getUserManager->image_retrieve($user_id);
echo' <center> <img src="data:image/jpeg;base64,'.($userimage['profile_image']).'" height="100" width="100"/> </center>';
$userimage=UserManager::image_retrieve($user_id);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe there is a function called getUserFromId

echo' <center> <img src="data:image/jpeg;base64,'.($userimage).'" height="100" width="100"/> </center>';
?>
<form method="post" enctype="multipart/form-data">
<input type="file" name="image" id="image" />
Expand All @@ -85,19 +98,19 @@ class="glyphicon glyphicon-user"></span> My Account</a></li>
<div id="information">
<div class="row">
<div class="container">
<form action="">
<form method="post" enctype="multipart/form-data">

<fieldset>
<legend id="legendA">Personal information</legend>
<label class="label">Name</label><br />
<!-- Needs to check for name inside of input box - link to back end-->
<input type="text" name="screen_name" class="textInput"> <br /><br />
<input type="text" name="screen_name" id="screen_name" class="textInput"> <br /><br />
<label class="label">Username</label><br />
<!--Need to insert a user check to retrieve ID -->
<input type="text" name="username" class="textInput"> <br /><br />
<input type="text" name="username" id="username" class="textInput"> <br /><br />

<label class="label">Bio</label><br />
<textarea name ="bio" class="textInput" maxlength="2000" placeholder="Enter your bio (max: apprx. 300 words)" rows = "10"></textarea><br /><br />
<textarea name ="bio" id="bio" class="textInput" maxlength="2000" placeholder="Enter your bio (max: apprx. 300 words)" rows = "10"></textarea><br /><br />


<label class="label">Country</label><span style="width:40px;"></span><br />
Expand Down Expand Up @@ -357,9 +370,9 @@ class="glyphicon glyphicon-user"></span> My Account</a></li>
<fieldset>
<legend id="legendA">Contact information and links</legend>
<label class="label">Email</label><br />
<input type="text" name="email" class="textInput"> <br /><br />
<input type="text" name="email" id="email" class="textInput"> <br /><br />
<label class="label">Website</label><br />
<input type="text" name="website" class="textInput"> <br /><br />
<input type="text" name="website" id="website" class="textInput"> <br /><br />
</fieldset>
<!-- The following code is meant to allow the change of password -->
<!--
Expand All @@ -369,7 +382,7 @@ class="glyphicon glyphicon-user"></span> My Account</a></li>
<input type = "password" name="usrNm"/>(6 to 20 characters)
</form>
-->
<input type="submit" value="Confirm">
<input type="submit" value="Confirm" name="confirm" id="confirm" />
<input type="reset" value="Start over">
</form>
</div>
Expand Down