$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; } } header("location: ./?page=settings"); } if (isset($_POST['action']) && $_POST['action'] == "settings"){ foreach($_POST as $key => $value){ switch($key){ case "explicit": $cookie[$index]['explicit'] = htmlentities($value); break; case "unrollcw": $cookie[$index]['unrollcw'] = htmlentities($value); break; /* case "emoji": $cookie[$index]['emoji'] = intval($value); break; */ case "defscope": $cookie[$index]['defscope'] = intval($value); break; case "text": $cookie[$index]['text'] = ($value == "on" ? "on" : "off"); break; case "attach": $cookie[$index]['attach'] = ($value == "on" ? "on" : "off"); break; case "replies": $cookie[$index]['replies'] = ($value == "on" ? "on" : "off"); break; case "theme": $cookie[$index]['theme'] = sanitize($value); break; case "notif": $cookie[$index]['notif'] = ""; $cookie[$index]['notif'] .= (isset($value['fav']) ? "1" : "0"); $cookie[$index]['notif'] .= (isset($value['rt']) ? "1" : "0"); $cookie[$index]['notif'] .= (isset($value['mnt']) ? "1" : "0"); $cookie[$index]['notif'] .= (isset($value['follow']) ? "1" : "0"); break; case "videoloop": $cookie[$index]['videoloop'] = ($value == "on" ? "on" : "off"); break; case "mute": $cookie[$index]['mute'] = ($value == "on" ? "on" : "off"); break; case "embyt": $cookie[$index]['embyt'] = ($value == "on" ? "on" : "off"); break; case "linkpv": $cookie[$index]['linkpv'] = ($value == "on" ? "on" : "off"); break; case "invidious": $cookie[$index]['invidious'] = (empty($value) ? "" : sanitize($value)); break; case "teddit": $cookie[$index]['teddit'] = (empty($value) ? "" : sanitize($value)); break; case "nitter": $cookie[$index]['nitter'] = (empty($value) ? "" : sanitize($value)); break; case "theme": $cookie[$index]['theme'] = sanitize($value); break; /* case "instance": if (!isset($_COOKIE['token'])){ $cookie[$index]['instance'] = htmlentities($value); } break; */ case "mtwords": $cookie[$index]['mtwords'] = array(); $mtwords = explode("\n",$value); foreach ($mtwords as $word){ $cookie[$index]['mtwords'][] = sanitize($word); } break; case "fhtags": $cookie[$index]['fhtags'] = array(); $fhtags = explode("\n",$value); foreach ($fhtags as $word){ $cookie[$index]['fhtags'][] = sanitize($word); } break; case "fg": $theme['fg'] = sanitize($value); break; case "bg": $theme['bg'] = sanitize($value); break; case "tx": $theme['tx'] = sanitize($value); break; case "lc": $theme['lc'] = sanitize($value); break; case "bc": $theme['bc'] = sanitize($value); break; case "br": $theme['br'] = sanitize($value); break; case "bw": $theme['bw'] = sanitize($value); break; case "dr": $theme['dr'] = sanitize($value); break; } } setrawcookie("user_settings", base64_encode(json_encode($cookie)) , time() + 60 * 60 * 24 * 30, '/'); setrawcookie("theme",base64_encode(json_encode($theme)),time()+60*60*24*30,'/'); header("location: ./?page=settings"); } $thread = (isset($_GET['thread']) ? htmlentities($_GET['thread']) : false); $mode = (isset($_GET['mode']) ? htmlentities($_GET['mode']) : false); $ajax = (isset($_GET['a']) ? true : false); foreach($_GET as $key => $value){ switch($key){ case "info": echo json_encode(array($token,$user_settings['instance'])); break; case "vote": $elem = array(); $elem['poll'] = json_decode(vote($value,$_GET['choices']),true); //var_dump($_GET['choices']); echo renderPoll($elem); break; case "fav": $result = favourite($value,($mode === 'on' ? true : false)); if ($ajax){ echo $result; die(); } else { header("Location: ?thread=".$value); } break; case "reblog": $result =reblog($value,($mode === 'on' ? true : false)); if ($ajax){ echo $result; die(); } else { header("Location: ?thread=".$value); } break; case "mute": if($thread){ $rel = api_post("statuses/".htmlentities($value)."/".($mode === 'true' ? "" : "un")."mute",array()); echo (isset($rel[0]['muting']) ? "1" : "0" ); } else { $rel = api_post("accounts/".htmlentities($value)."/".($mode === 'true' ? "" : "un")."mute",array()); echo (isset($rel[0]['muting']) ? "1" : "0" ); } die(); break; case "softmute": if (!isset($user_settings['softmute'])){ $user_settings['softmute'] = array(); $cookie[$index]['softmute'] = array(); } $user_settings['softmute'][] = sanitize($value); $cookie[$index]['softmute'] = $user_settings['softmute']; setrawcookie("user_settings", base64_encode(json_encode($cookie)) , time() + 60 * 60 * 24 * 30, '/'); echo "1"; die(); break; case "list": if($mode === 'true'){ $rel = api_post("lists/".htmlentities($value)."/accounts?account_ids[]=".$_GET['user'],array()); var_dump($rel); } else { $rel = api_delete("lists/".htmlentities($value)."/accounts?account_ids[]=".$_GET['user'],array()); var_dump($rel); } die(); break; case "listdelete": $rel = api_delete("lists/".htmlentities($value),array()); die(); break; case "softmutedelete": $key = array_search(sanitize($value),$user_settings['softmute']); unset($user_settings['softmute'][$key]); unset($cookie[$index]['softmute'][$key]); setrawcookie("user_settings", base64_encode(json_encode($cookie)) , time() + 60 * 60 * 24 * 30, '/'); die(); break; case "listnew": $rel = api_post("lists/",array("title" => htmlentities($value))); die(); break; case "block": $rel = api_post("accounts/".htmlentities($value)."/".($mode === 'true' ? "" : "un")."block",array()); echo (isset($rel[0]['blocking']) ? "1" : "0" ); die(); break; case "bookmark": $status = api_get("statuses/".htmlentities($value)); $rel = api_post("statuses/".htmlentities($value)."/".($status['bookmarked'] == 'true' ? "un" : "")."bookmark",array()); die(); break; case "notif": echo getnotif(intval($value),(isset($_GET['max']) ? true : false)); die(); break; case "delete": echo delpost(htmlentities($value)); die(); break; case "replies": $since = (isset($_GET['since']) ? htmlentities($_GET['since']) : false); foreach(getreplies(htmlentities($value),$since) as $elem){ echo render_reply($elem['content']); } die(); break; case "notes": $notes = getnotes($value); foreach ($notes as $note){ echo "
"; } die(); break; case "follow": $rel = api_post("accounts/".htmlentities($value)."/follow",array()); echo ($rel['following'] == true || $rel['requested'] == true ? "1" : "0" ); die(); break; case "unfollow": $rel = api_post("accounts/".htmlentities($value)."/unfollow",array()); echo ($rel['following'] == false ? "1" : "0" ); die(); break; case "nsfw": if(in_array($value,$user_settings['nsfw'])){ $key = array_search($value, $user_settings['nsfw']); unset($user_settings['nsfw'][$key]); $cookie[$index]['nsfw'] = $user_settings['nsfw']; setrawcookie("user_settings", base64_encode(json_encode($cookie)) , time() + 60 * 60 * 24 * 30, '/'); } else { $user_settings['nsfw'][] = htmlentities($value); $cookie[$index]['nsfw'] = $user_settings['nsfw']; setrawcookie("user_settings", base64_encode(json_encode($cookie)) , time() + 60 * 60 * 24 * 30, '/'); } echo "1"; die(); break; case "hide": if(!isset($user_settings['hide'])|| !is_array($user_settings['hide'])){ $user_settings['hide'] = array(); } if(in_array($value,$user_settings['hide'])){ $key = array_search($value, $user_settings['hide']); unset($user_settings['hide'][$key]); $cookie[$index]['hide'] = $user_settings['hide']; setrawcookie("user_settings", base64_encode(json_encode($cookie)) , time() + 60 * 60 * 24 * 30, '/'); } else { $user_settings['hide'][] = htmlentities($value); $cookie[$index]['hide'] = $user_settings['hide']; setrawcookie("user_settings", base64_encode(json_encode($cookie)) , time() + 60 * 60 * 24 * 30, '/'); } echo "1"; die(); break; case "userinfo": $info = api_get("accounts/".htmlentities($value)); $rel = api_get("accounts/relationships?id=".htmlentities($value)); /* $photos = api_get("accounts/".htmlentities($value)."/statuses?only_media=true&limit=5&exclude_reblogs=true"); $photo = array(); $c = 0; if (!empty($photos)){ foreach ($photos as $elem){ if ($elem['media_attachments'][0]['type'] == "image"){ $photo[$c]['url'] = $elem['media_attachments'][0]['url']; if ($elem['sensitive'] == true){ $photo[$c]['s'] = true; } $c++; } if ($c == 3){ break; } } } */ echo " Follows You
" : "")." ".($logedin ? "".($rel[0]['following'] || $rel[0]['requested'] ? "Following" : "Follow" )."" : "")." ".(in_array($info['id'],$user_settings['nsfw']) ? "NSFW " : "NSFW " )." ".($logedin ? "" . ($rel[0]['muting'] ? " Unmute" : " Mute") . "" : "")."