290420 New theme, personal settings and bugfixes

This commit is contained in:
Daisuke
2020-04-29 12:29:25 -05:00
parent 16e39ffbe8
commit 687ddc7068
48 changed files with 1986 additions and 369 deletions

View File

@ -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 .= "<br>";
$votes = $elem['poll']['votes_count'];
@ -246,7 +295,7 @@ function renderPoll($elem) {
foreach ($elem['poll']['options'] as $option){
$output .= "<div class='polloption'>".$option['title']."</div>";
}
$output .= "<input type='submit' class='vote' id='".$elem['poll']['id']."' value='Send Vote' style='padding:2px;' onClick='return false;'>";
$output .= ($logedin ? "<input type='submit' class='vote' id='".$elem['poll']['id']."' value='Send Vote' style='padding:2px;' onClick='return false;'>" : "");
}
return $output;
}
@ -306,7 +355,7 @@ function render_reply($item) {
$unlisted = "&#xe816;";
$direct = "&#xf0e0;";
$reply['date'] = "<a class='ldr postAge' id='".strtotime($item['created_at'])."' style='text-decoration:none;' target='_blank' href='?thread=" . $item['id'] . "&instance=$srv" . "'>" . time_elapsed_string($item['created_at']) . "</a> - <span class='fontello'>" . $$item['visibility'] . "</span>";
$reply['date'] = "<a class='ldr postAge' id='".strtotime($item['created_at'])."' style='text-decoration:none;' target='_blank' href='?thread=" . $item['id'] . "'>" . time_elapsed_string($item['created_at']) . "</a> - <span class='fontello ".$item['visibility']."'> </span>";
$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;
}
}