diff --git a/README.md b/README.md
index 2cdbe0e..fe1c134 100644
--- a/README.md
+++ b/README.md
@@ -20,4 +20,10 @@ Enjoy
# Update
-If you wish to update your instalation to a newer version, just download the package and overwrite all changed files (except for settings.php file unless explicitly directd to)
\ No newline at end of file
+Option 1:
+
+Download package and replace all files with different size (except settings.php on root).
+
+Option 2:
+
+Delete everything (except settings.php on root and /data folder) and reupload.
\ No newline at end of file
diff --git a/action.php b/action.php
index b4354c7..8306dec 100644
--- a/action.php
+++ b/action.php
@@ -16,11 +16,41 @@ require_once "include/functions.php";
$srv = $user_settings['instance'];
-if (isset($_GET['action']) && $_GET['action'] == "settings"){
- //file_put_contents("settings.txt",var_export($_GET,true));
-
- foreach($_GET as $key => $value){
+if (isset($_POST['action']) && $_POST['action'] == "settings"){
+ if(!empty($_FILES["avatar"]["name"])){
+ $ext = strtolower(end(explode('.', $_FILES["avatar"]['name'])));
+ if(in_array($ext,array("jpg","jpeg","gif","png"))){
+ $file_name = time().mt_rand(100,199).".".$ext;
+ $file_tmp = $_FILES["avatar"]['tmp_name'];
+ move_uploaded_file($file_tmp, $file_name);
+ upload_profile($file_name,'avatar');
+ unlink($file_name);
+ } else {
+ unlink($_FILES["avatar"]['tmp_name']);
+ }
+ }
+ if(!empty($_FILES["header"]["name"])){
+ $ext = strtolower(end(explode('.', $_FILES["header"]['name'])));
+ if(in_array($ext,array("jpg","jpeg","gif","png"))){
+ $file_name = time().mt_rand(100,199).".".$ext;
+ $file_tmp = $_FILES["header"]['tmp_name'];
+ move_uploaded_file($file_tmp, $file_name);
+ upload_profile($file_name,'header');
+ unlink($file_name);
+ } else {
+ unlink($_FILES["header"]['tmp_name']);
+ }
+ }
+ foreach($_POST as $key => $value){
switch($key){
+ case "username":
+ api_patch("accounts/update_credentials",array('display_name'=>$value));
+ break;
+
+ case "bio":
+ api_patch("accounts/update_credentials",array('note'=>$value));
+ break;
+
case "explicit":
$user_settings['explicit'] = htmlentities($value);
break;
@@ -98,7 +128,7 @@ if (isset($_GET['action']) && $_GET['action'] == "settings"){
}
setrawcookie("user_settings",base64_encode(json_encode($user_settings)),time()+60*60*24*30,'/');
setrawcookie("theme",base64_encode(json_encode($theme)),time()+60*60*24*30,'/');
- die();
+ header("location: ./?page=settings");
}
@@ -263,6 +293,7 @@ foreach($_GET as $key => $value){
".($logedin ? "".($rel[0]['following'] || $rel[0]['requested'] ? "Following" : "Follow" )."" : "")."
".(in_array($info['id'],$user_settings['nsfw']) ? "NSFW " : "NSFW " )."
+ ".($logedin ? "" . ($rel[0]['muting'] ? " Unmute" : " Mute") . "" : "")."
";
@@ -284,11 +315,15 @@ foreach($_GET as $key => $value){
case "themefile":
- //echo $value;
echo themes("get",$value);
die();
break;
+ case "themename":
+ echo $user_settings['theme'];
+ die();
+ break;
+
case "emoji":
echo emoji_list(sanitize($value));
//die();
diff --git a/css/color.css b/css/color.css
index 09d945e..6aaa81e 100644
--- a/css/color.css
+++ b/css/color.css
@@ -253,6 +253,24 @@ input[type="submit"] {
background-color: #eee;
}
+.public::after {
+ content: '';
+}
+
+.unlisted::after {
+ content: '';
+}
+
+.private::after {
+ content: '';
+}
+
+.direct::after {
+ content: '';
+}
+
+
+
.post_buttons {
color: #404040;
}
diff --git a/css/mobile.css b/css/mobile.css
index cd51a7b..d769b47 100644
--- a/css/mobile.css
+++ b/css/mobile.css
@@ -233,7 +233,7 @@ aside {
height: 60px;
border: 1px solid #ccc;
display: inline-block;
- box-shadow: 3px 3px 3px grey;
+ box-shadow: 3px 3px 3px rgba(0, 0, 0, 0.3);
float: left;
background-size: cover;
}
@@ -360,10 +360,9 @@ aside {
}
.avatar {
- display:none;
- width: 50px;
- background-size: cover;
- height: 50px;
+ width: 80px;
+ background-size: 80px;
+ height: 80px;
float: left;
margin: 15px;
border-radius: 10px;
@@ -423,20 +422,28 @@ aside {
display: none;
position: absolute;
left:0px;
- top:-198px;
+ top:15px;
width: 300px;
- height: 200px;
+ height: auto;
border-radius:3px;
+ line-height:initial;
+ z-index:99;
+}
+
+.userinfo_upper{
+ top:-100px;
}
.userinfo_co {
width: 280px;
margin: 10px;
+ text-align: center;
+ position:relative;
}
.userinfo_he {
width: 300px;
- height: 100px;
+ height: 150px;
}
.media {
diff --git a/css/style.css b/css/style.css
index 13722d6..42f31ca 100644
--- a/css/style.css
+++ b/css/style.css
@@ -233,7 +233,7 @@ aside {
height: 60px;
border: 1px solid #ccc;
display: inline-block;
- box-shadow: 3px 3px 3px grey;
+ box-shadow: 3px 3px 3px rgba(0, 0, 0, 0.3);
float: left;
background-size: cover;
}
@@ -360,11 +360,11 @@ aside {
.avatar {
width: 80px;
- background-size: 80px;
height: 80px;
float: left;
margin: 15px;
border-radius: 10px;
+ background-size: auto 80px;
}
.post,
diff --git a/include/functions.php b/include/functions.php
index f923c9a..ba191d6 100644
--- a/include/functions.php
+++ b/include/functions.php
@@ -230,8 +230,57 @@ function api_delete($url, $array) {
return json_decode($result, true);
}
+/* a function to make general PATCH api calls to the logged-in instance*/
+function api_patch($url, $array) {
+ global $srv;
+ global $token;
+
+ $cSession = curl_init();
+ curl_setopt($cSession, CURLOPT_HEADER, false);
+ curl_setopt($cSession, CURLOPT_POST, 1);
+ curl_setopt($cSession, CURLOPT_URL, "https://$srv/api/v1/" . $url);
+ curl_setopt($cSession, CURLOPT_CUSTOMREQUEST, "PATCH");
+ if (!is_null($token)) {
+ curl_setopt($cSession, CURLOPT_HTTPHEADER, array(
+ 'Authorization: Bearer ' . $token
+ ));
+ }
+ curl_setopt($cSession, CURLOPT_POSTFIELDS, http_build_query($array));
+ curl_setopt($cSession, CURLOPT_RETURNTRANSFER, true);
+ $result = curl_exec($cSession);
+ curl_close($cSession);
+
+ return json_decode($result, true);
+}
+
+function upload_profile($file,$type){
+ global $srv;
+ global $token;
+
+ $mime = get_mime($file);
+ $info = pathinfo($file);
+ $name = $info['basename'];
+ $output = new CURLFile($file, $mime, $name);
+ $cSession = curl_init();
+ curl_setopt($cSession, CURLOPT_URL, "https://$srv/api/v1/accounts/update_credentials");
+ curl_setopt($cSession, CURLOPT_RETURNTRANSFER, true);
+ curl_setopt($cSession, CURLOPT_POST, 1);
+ curl_setopt($cSession, CURLOPT_CUSTOMREQUEST, "PATCH");
+ curl_setopt($cSession, CURLOPT_HTTPHEADER, array(
+ 'Authorization: Bearer ' . $token
+ ));
+ curl_setopt($cSession, CURLOPT_POSTFIELDS, array(
+ $type => $output
+ ));
+ $result = curl_exec($cSession);
+ curl_close($cSession);
+ return $result;
+}
+
/* this function is used to generate the html code of a poll */
function renderPoll($elem) {
+ global $logedin;
+
$output = "";
$output .= "
";
$votes = $elem['poll']['votes_count'];
@@ -246,7 +295,7 @@ function renderPoll($elem) {
foreach ($elem['poll']['options'] as $option){
$output .= "
".$option['title']."
";
}
- $output .= "";
+ $output .= ($logedin ? "" : "");
}
return $output;
}
@@ -306,7 +355,7 @@ function render_reply($item) {
$unlisted = "";
$direct = "";
- $reply['date'] = "" . time_elapsed_string($item['created_at']) . " - " . $$item['visibility'] . "";
+ $reply['date'] = "" . time_elapsed_string($item['created_at']) . " - ";
$reply['media'] = "";
if (!empty($item['media_attachments'])) {
@@ -494,8 +543,6 @@ function uploadpic($file) {
$info = pathinfo($file);
$name = $info['basename'];
$output = new CURLFile($file, $mime, $name);
-
- do {
$cSession = curl_init();
curl_setopt($cSession, CURLOPT_URL, "https://$srv/api/v1/media");
curl_setopt($cSession, CURLOPT_RETURNTRANSFER, true);
@@ -507,7 +554,6 @@ function uploadpic($file) {
'file' => $output
));
$result = curl_exec($cSession);
- } while (empty($result));
curl_close($cSession);
$array = json_decode($result, true);
@@ -938,7 +984,7 @@ function themes($mode,$name = false){
$themes = scandir("themes/");
$themelist = array();
foreach ($themes as $elem){
- if ($elem != ".." && $elem != "." && $elem != "custom"){
+ if ($elem != ".." && $elem != "." && $elem != "custom" && is_dir("themes/".$elem)){
$themelist[] = $elem;
}
}
diff --git a/index.php b/index.php
index 95ff8a3..33907e3 100644
--- a/index.php
+++ b/index.php
@@ -42,8 +42,16 @@ include "settings.php"; # the general settings of the FE
include "include/init.php"; # initializes the page load with some variables and cookies
include "include/functions.php"; # the functions that are used on all the FE files.
+if ($logedin){
+ $info = api_get("accounts/verify_credentials");
+ if(!$info['display_name']){
+ header('Location: ./logout');
+ }
+}
+
+
/* if part of the url query is an ajax action, this file will handle it */
-if(isset($_GET['action'])){
+if(isset($_GET['action']) || isset($_POST['action'])){
include "action.php";
}
diff --git a/js/scripts.js b/js/scripts.js
index 853655c..5bffad6 100644
--- a/js/scripts.js
+++ b/js/scripts.js
@@ -112,7 +112,7 @@ $('body').on('click', '.ldr', function(e) {
var url = $(this).attr('href');
var id = $(this).attr('id');
localStorage.setItem("content", $('#content .element').detach());
- $('#content').html('');
+ $('#content').html('');
$.get(url + "&ajax=1", function(data) {
$('#content').html(data);
history.pushState({}, "Dashboard FE", url);
@@ -120,6 +120,7 @@ $('body').on('click', '.ldr', function(e) {
});
});
+
$('body').on('click', '.gotop a', function(e) {
e.preventDefault();
$('html, body').animate({
@@ -432,6 +433,7 @@ window.setInterval(function() {
newPosts();
}, 25000);
+/*
$('body').on('click', '#settings #send', function() {
$('#settings #send').after('');
var params = {
@@ -458,7 +460,7 @@ $('body').on('click', '#settings #send', function() {
window.location.reload(true);
});
});
-
+*/
function themecheck(name){
if(name.value == "custom"){
@@ -469,7 +471,6 @@ function themecheck(name){
}
};
-
function timeSince(date) {
/* https://stackoverflow.com/questions/3177836/how-to-format-time-since-xxx-e-g-4-minutes-ago-similar-to-stack-exchange-site */
@@ -478,27 +479,27 @@ function timeSince(date) {
var interval = Math.floor(seconds / 31536000);
if (interval >= 1) {
- return interval + " years";
+ return interval + " year"+(interval > 1 ? "s" : "");
}
interval = Math.floor(seconds / 2592000);
if (interval >= 1) {
- return interval + " months";
+ return interval + " month"+(interval > 1 ? "s" : "");
}
interval = Math.floor(seconds / 604800);
if (interval >= 1) {
- return interval + " weeks";
+ return interval + " week"+(interval > 1 ? "s" : "");
}
interval = Math.floor(seconds / 86400);
if (interval >= 1) {
- return interval + " days";
+ return interval + " day"+(interval > 1 ? "s" : "");
}
interval = Math.floor(seconds / 3600);
if (interval >= 1) {
- return interval + " hours";
+ return interval + " hour"+(interval > 1 ? "s" : "");
}
interval = Math.floor(seconds / 60);
if (interval >= 1) {
- return interval + " minutes";
+ return interval + " minute"+(interval > 1 ? "s" : "");
}
return Math.floor(seconds) + " seconds";
}
\ No newline at end of file
diff --git a/layout/footer.php b/layout/footer.php
index d888873..c829d96 100644
--- a/layout/footer.php
+++ b/layout/footer.php
@@ -382,68 +382,68 @@ $query = http_build_query(array_filter(array(
});
- document.onpaste = function (event) {
- var items = (event.clipboardData || event.originalEvent.clipboardData).items;
- /*Make Sure Only One File is Copied*/
- if (items.length != 1) {
- return;
- }
- var item = items[0];
- /*Verify If The Copied Item is File*/
- if (item.kind === 'file') {
- var file = item.getAsFile();
- var filename = file.name;
- /*Get File Extension*/
- var ext = filename.split('.').reverse()[0].toLowerCase();
- /*Check Image File Extensions*/
- if (jQuery.inArray(ext, ['jpg', 'png']) > -1) {
- /*Create FormData Instance*/
- var data = new FormData();
- data.append('file', file);
- /*Request Ajax With File*/
- request_ajax_file('upload.php', data, file_uploaded);
- } else {
- alert('Invalid File');
- }
- }
- };
+ document.onpaste = function (event) {
+ var items = (event.clipboardData || event.originalEvent.clipboardData).items;
+ /*Make Sure Only One File is Copied*/
+ if (items.length != 1) {
+ return;
+ }
+ var item = items[0];
+ /*Verify If The Copied Item is File*/
+ if (item.kind === 'file') {
+ var file = item.getAsFile();
+ var filename = file.name;
+ /*Get File Extension*/
+ var ext = filename.split('.').reverse()[0].toLowerCase();
+ /*Check Image File Extensions*/
+ if (jQuery.inArray(ext, ['jpg', 'png']) > -1) {
+ /*Create FormData Instance*/
+ var data = new FormData();
+ data.append('file', file);
+ /*Request Ajax With File*/
+ request_ajax_file('upload.php', data, file_uploaded);
+ } else {
+ alert('Invalid File');
+ }
+ }
+ };
- function file_uploaded(data) {
- if ($("#postform .uploadBox").length < 1){
- $("#postform #status").before('');
- $( function() {
- $( "#files" ).sortable();
- $( "#files" ).disableSelection();
- } );
+ function file_uploaded(data) {
+ if ($("#postform .uploadBox").length < 1){
+ $("#postform #status").before('');
+ $( function() {
+ $( "#files" ).sortable();
+ $( "#files" ).disableSelection();
+ } );
+ }
+ var files = JSON.parse(data);
+ $.each(files, function( index, elem ) {
+ $("#files").append('
');
+ });
+ var nfiles = $("#postform .uploadBox").children().length;
+ $("#postform .status").html('');
+ }
+
+ /*Function to Make AJAX Request With File*/
+ function request_ajax_file(ajax_url, ajax_data, ajax_callback) {
+ $("#postform .status").html('');
+ jQuery.ajax({
+ url: ajax_url,
+ data: ajax_data,
+ type: 'POST',
+ processData: false,
+ contentType: false,
+ success: function (response) {
+ if (typeof ajax_callback == 'function') {
+ ajax_callback(response);
+ } else if (typeof ajax_callback == 'string') {
+ if (ajax_callback != '') {
+ eval(ajax_callback + '(response)');
+ }
}
- var files = JSON.parse(data);
- $.each(files, function( index, elem ) {
- $("#files").append('
');
- });
- var nfiles = $("#postform .uploadBox").children().length;
- $("#postform .status").html('');
- }
-
- /*Function to Make AJAX Request With File*/
- function request_ajax_file(ajax_url, ajax_data, ajax_callback) {
- $("#postform .status").html('');
- jQuery.ajax({
- url: ajax_url,
- data: ajax_data,
- type: 'POST',
- processData: false,
- contentType: false,
- success: function (response) {
- if (typeof ajax_callback == 'function') {
- ajax_callback(response);
- } else if (typeof ajax_callback == 'string') {
- if (ajax_callback != '') {
- eval(ajax_callback + '(response)');
- }
- }
- }
- });
- }
+ }
+ });
+ }
function upload_files() {
$("#postform .status").html('');
diff --git a/layout/header.php b/layout/header.php
index d61f767..9e15cdb 100644
--- a/layout/header.php
+++ b/layout/header.php
@@ -1,12 +1,6 @@
-
-
-
- ?id=' />
-
-
+
+
+
+ ?id=' />
+
+
+
▲
diff --git a/login/index.php b/login/index.php
index 6a21786..776fa81 100644
--- a/login/index.php
+++ b/login/index.php
@@ -9,7 +9,7 @@ include "../include/functions.php";
$message = "";
if (isset($_POST['user']) || isset($_GET['instance'])){
- $instance = (isset($_POST['user']) ? htmlentities($_POST['user']) : htmlentities($_GET['instance']));
+ $instance = strtolower((isset($_POST['user']) ? htmlentities($_POST['user']) : htmlentities($_GET['instance'])));
$check = json_decode(file_get_contents("https://$instance/api/v1/instance"),true);
if(is_null($check['title'])){
diff --git a/logout/index.php b/logout/index.php
index f627ccc..490c43a 100644
--- a/logout/index.php
+++ b/logout/index.php
@@ -1,4 +1,4 @@