mirror of https://github.com/pikami/palm-paste.git
Users can now see a list of their pastes
This commit is contained in:
parent
df2eabccb0
commit
04a6be87a5
|
@ -0,0 +1,36 @@
|
||||||
|
<div class="container">
|
||||||
|
<div class="panel panel-default">
|
||||||
|
<div class="panel-body">
|
||||||
|
<?php
|
||||||
|
include "config/config.php";
|
||||||
|
include_once "includes/user.php";
|
||||||
|
if(GetUsersIDBySession($_COOKIE["pp_sid"],$_COOKIE["pp_skey"]) == -1){
|
||||||
|
printf('<h2>You must be loged in to see your pastes!</h2>');
|
||||||
|
$conn = null;
|
||||||
|
echo '</div></div></div>';
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
$stmt = $conn->prepare('SELECT * FROM pastes WHERE owner=:own');
|
||||||
|
$stmt->bindParam(':own', GetUsersIDBySession($_COOKIE["pp_sid"],$_COOKIE["pp_skey"]));
|
||||||
|
$stmt->execute();
|
||||||
|
if($stmt->rowCount()>0){
|
||||||
|
echo "<table id=\"tablepastes\" class=\"table table-striped\" style=\"width:100%\">";
|
||||||
|
printf('<thead><th data-dynatable-column="name" style="text-align: left;">Title</th>
|
||||||
|
<th style="text-align: left;">Added</th>
|
||||||
|
<th style="text-align: left;">ID</th></thead>');
|
||||||
|
printf('<tbody>');
|
||||||
|
while($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||||
|
$title = $row['title'];
|
||||||
|
printf('<tr><td style="text-align: left;">'.$row["title"].'</td>');
|
||||||
|
printf('<td style="text-align: left;">'.date('Y-m-d',$row["created"]).'</td>');
|
||||||
|
printf('<td style="text-align: right;"><a href="'.$row["uid"].'">'.$row["uid"].'</a></td></tr>');
|
||||||
|
}
|
||||||
|
printf('</tbody></talbe>');
|
||||||
|
} else {
|
||||||
|
printf('<h2>You havent made any pastes yet!</h2>');
|
||||||
|
}
|
||||||
|
$conn = null;
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
|
@ -1,2 +1,3 @@
|
||||||
|
# Palm-paste
|
||||||
This is a script of a site where you can share text and code snippets.
|
This is a script of a site where you can share text and code snippets.
|
||||||
It's not finished so don't use it yet!
|
It's not finished so don't use it yet!
|
|
@ -8,7 +8,7 @@ if(isset($uid)){
|
||||||
$stmt = $conn->query('SELECT * FROM pastes WHERE uid="'.$uid.'"');
|
$stmt = $conn->query('SELECT * FROM pastes WHERE uid="'.$uid.'"');
|
||||||
if($result = $stmt->fetch(PDO::FETCH_ASSOC)){
|
if($result = $stmt->fetch(PDO::FETCH_ASSOC)){
|
||||||
$conn = null;
|
$conn = null;
|
||||||
if($result["exposure"]==2 && $result["owner"]!=GetUsersIDBySession($_COOKIE["pp_sid"],$_COOKIE["pp_skey"])){
|
if($result["exposure"]==2 && isset($_COOKIE["pp_sid"]) && isset($_COOKIE["pp_skey"]) && $result["owner"]!=GetUsersIDBySession($_COOKIE["pp_sid"],$_COOKIE["pp_skey"])){
|
||||||
echo "<h1>This paste is private</h1>";
|
echo "<h1>This paste is private</h1>";
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,104 @@
|
||||||
|
/*
|
||||||
|
* jQuery Dynatable plugin 0.3.1
|
||||||
|
*
|
||||||
|
* Copyright (c) 2014 Steve Schwartz (JangoSteve)
|
||||||
|
*
|
||||||
|
* Dual licensed under the AGPL and Proprietary licenses:
|
||||||
|
* http://www.dynatable.com/license/
|
||||||
|
*
|
||||||
|
* Date: Tue Jan 02 2014
|
||||||
|
*/
|
||||||
|
th a {
|
||||||
|
color: #000;
|
||||||
|
}
|
||||||
|
th a:hover {
|
||||||
|
color: #000;
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
.dynatable-per-page-select{
|
||||||
|
border: 1px solid #111;
|
||||||
|
background: transparent;
|
||||||
|
width: 150px;
|
||||||
|
padding: 5px 35px 5px 5px;
|
||||||
|
margin-bottom: -1000px;
|
||||||
|
font-size: 16px;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
-webkit-appearance: none;
|
||||||
|
-moz-appearance: none;
|
||||||
|
appearance: none;
|
||||||
|
}
|
||||||
|
.dynatable-per-page{
|
||||||
|
color: #000;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dynatable-search {
|
||||||
|
float: right;
|
||||||
|
margin-right: 33px;
|
||||||
|
color: #000;
|
||||||
|
}
|
||||||
|
.dynatable-search > input{
|
||||||
|
border: 1px solid #111;
|
||||||
|
background: transparent;
|
||||||
|
width: 150px;
|
||||||
|
padding: 5px 35px 5px 5px;
|
||||||
|
|
||||||
|
font-size: 16px;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
-webkit-appearance: none;
|
||||||
|
-moz-appearance: none;
|
||||||
|
appearance: none;
|
||||||
|
|
||||||
|
}
|
||||||
|
.dynatable-pagination-links {
|
||||||
|
float: right;
|
||||||
|
color: #000;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dynatable-record-count {
|
||||||
|
display: block;
|
||||||
|
|
||||||
|
color: #000;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dynatable-pagination-links span,
|
||||||
|
.dynatable-pagination-links li {
|
||||||
|
display: inline-block;
|
||||||
|
color: #000;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dynatable-page-link,
|
||||||
|
.dynatable-page-break {
|
||||||
|
display: block;
|
||||||
|
padding: 5px 7px;
|
||||||
|
color: #000;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dynatable-page-link {
|
||||||
|
cursor: pointer;
|
||||||
|
color: #000;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dynatable-active-page,
|
||||||
|
.dynatable-disabled-page {
|
||||||
|
cursor: text;
|
||||||
|
color: #000;
|
||||||
|
}
|
||||||
|
.dynatable-active-page:hover,
|
||||||
|
.dynatable-disabled-page:hover {
|
||||||
|
text-decoration: none;
|
||||||
|
color: #000;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dynatable-active-page {
|
||||||
|
background: #00CED1;
|
||||||
|
border-radius: 5px;
|
||||||
|
color: #000;
|
||||||
|
}
|
||||||
|
.dynatable-active-page:hover {
|
||||||
|
color: #000;
|
||||||
|
}
|
||||||
|
.dynatable-disabled-page,
|
||||||
|
.dynatable-disabled-page:hover {
|
||||||
|
background: none;
|
||||||
|
color: #000;
|
||||||
|
}
|
|
@ -7,6 +7,10 @@
|
||||||
<link rel="stylesheet" href="css/bootstrap.min.css">
|
<link rel="stylesheet" href="css/bootstrap.min.css">
|
||||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
|
||||||
<script src="js/bootstrap.min.js"></script>
|
<script src="js/bootstrap.min.js"></script>
|
||||||
|
|
||||||
|
<script type="text/javascript" src="js/jquery.dynatable.js"></script>
|
||||||
|
<link href="css/jquery.dynatable.css" rel="stylesheet">
|
||||||
|
<script>$(document).ready(function(){$('#tablepastes').dynatable();});</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<!-- NavBar -->
|
<!-- NavBar -->
|
||||||
|
@ -35,8 +39,7 @@
|
||||||
<li class="dropdown">
|
<li class="dropdown">
|
||||||
<a class="dropdown-toggle glyphicon glyphicon-user" data-toggle="dropdown" href="#"> '.$user[1].'<span class="caret"></span></a>
|
<a class="dropdown-toggle glyphicon glyphicon-user" data-toggle="dropdown" href="#"> '.$user[1].'<span class="caret"></span></a>
|
||||||
<ul class="dropdown-menu">
|
<ul class="dropdown-menu">
|
||||||
<li><a href="#">Placeholder</a></li>
|
<li><a href="mypastes">My pastes</a></li>
|
||||||
<li><a href="#">Placeholder</a></li>
|
|
||||||
<li><a href="logout">Logout</a></li>
|
<li><a href="logout">Logout</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
|
@ -86,6 +89,8 @@
|
||||||
if (isset($_GET["page"])){
|
if (isset($_GET["page"])){
|
||||||
if($_GET["page"] == "create"){
|
if($_GET["page"] == "create"){
|
||||||
include "NewPaste.php";
|
include "NewPaste.php";
|
||||||
|
} else if($_GET["page"] == "mypastes"){
|
||||||
|
include "MyPastes.php";
|
||||||
} else if($_GET["page"] == "login"){
|
} else if($_GET["page"] == "login"){
|
||||||
include "login.php";
|
include "login.php";
|
||||||
} else if($_GET["page"] == "logout"){
|
} else if($_GET["page"] == "logout"){
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
16
login.php
16
login.php
|
@ -55,8 +55,22 @@ if(isset($_GET["logout"])){
|
||||||
$user = $_POST["user"];
|
$user = $_POST["user"];
|
||||||
$pwd = $_POST["pwd"];
|
$pwd = $_POST["pwd"];
|
||||||
$hash = password_hash($pwd ,CRYPT_BLOWFISH);
|
$hash = password_hash($pwd ,CRYPT_BLOWFISH);
|
||||||
//Register the user
|
//Does this user exist
|
||||||
include "config/config.php";
|
include "config/config.php";
|
||||||
|
$stmt = $conn->prepare('SELECT * FROM users WHERE user=?');
|
||||||
|
$stmt->execute(array($user));
|
||||||
|
if($result = $stmt->fetch(PDO::FETCH_ASSOC)){
|
||||||
|
echo "<div class=\"container\"><h2>User allready exists!</h2></div>";
|
||||||
|
$conn = null;
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
//Did the person enter a password
|
||||||
|
if($pwd==""){
|
||||||
|
echo "<div class=\"container\"><h2>You need a password to singup!</h2></div>";
|
||||||
|
$conn = null;
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
//Register the user
|
||||||
$stmt = $conn->prepare("INSERT INTO users (user,password)
|
$stmt = $conn->prepare("INSERT INTO users (user,password)
|
||||||
VALUES (:user, :pwd)");
|
VALUES (:user, :pwd)");
|
||||||
$stmt->bindParam(':user', $user);
|
$stmt->bindParam(':user', $user);
|
||||||
|
|
Loading…
Reference in New Issue