This commit is contained in:
2022-10-06 22:04:13 +02:00
commit 4bc486fd92
487 changed files with 19040 additions and 0 deletions
+724
View File
@@ -0,0 +1,724 @@
<?php
header("Content-type: text/html; charset=UTF-8");
require_once( 'lib/config.php' );
// No JS - redirect to GET search url
if( isset($_POST['q']) ) {
header( 'location: '.Config::$absolutePath.'search/'.$_POST['q'] );
exit;
}
function validInvite($inv){
$inviteData = DB::getRow("SELECT * FROM pl_invites WHERE code=:1",$inv);
if($inviteData){
if($inviteData["used"] == 0){
$UserCheck = DB::getRow("SELECT spamblocked FROM pl_users WHERE id=:1",$inviteData["owner"]);
$BanCheck = DB::getRow("SELECT id FROM pl_banned WHERE id=:1",$inviteData["owner"]);
if($BanCheck){
return false;
}
if(int($UserCheck["spamblocked"]) ==1){
DB::insertRow("pl_banned",array("id"=>$inviteData["owner"],"reason"=>"Invitemissbrauch"));
return false;
}
return true;
}else{
return false;
}
}else{
return false;
}
}
/*require_once( 'lib/cache.php' );
$cache = new Cache( Config::$cache['path'], !empty($_GET['s']) ? $_GET['s'] : 'index' );
if( !Config::$cache['enabled'] ) {
$cache->disable();
}
// no session or remember cookie -> get the page from cache
if(
empty($_COOKIE[Config::$sessionCookie]) &&
empty($_COOKIE[Config::$rememberCookie])
) {
$cache->lookup();
}
*/
require_once( 'lib/users.php' );
require_once( 'lib/db.php' );
/*include('templates/closed.php');
exit();*/
// If the User logged in with POST or a remember cookie, we need forumops.php
// to log him in the forum, too.
if(isset($_POST['login']) || (empty($_COOKIE[Config::$sessionCookie]) && !empty($_COOKIE[Config::$rememberCookie]))) {
if( Config::$vbbIntegration['enabled'] ) { require_once( 'lib/class.forumops.php' ); }
}
$user = new User();
$messages = array();
$LoginState = $user->login();
list($ban, $reason) = split('[/.-]', $LoginState);
if( $ban == "ban"){
if(strlen($reason) > 2){
$messages['bannedLogin'] = $reason;
}else{
$messages['bannedLogin'] = true;
}
include( Config::$templates.'login.tpl.php' );
exit();
}
if( $user->id ) {
// Don't cache pages for logged-in users
//$cache->disable();
}
$query = !empty($_GET['s']) ? $_GET['s'] : '';
$r = explode( '/', $query );
$user->loadEmail();
if( $r[0] == 'login' ) { //---------------------------------------- login
if( Config::$vbbIntegration['enabled'] ) { require_once( 'lib/class.forumops.php' ); }
if( !empty( $r[1] ) ) {
if( $user->validate($r[1]) ) {
header( 'location: '.Config::$absolutePath );
} else {
header( 'location: '.Config::$absolutePath.'login' );
}
exit(0);
}
if( $user->id ) {
header( 'location: '.Config::$absolutePath );
exit();
}
if( isset($_POST['login']) ) {
if($LoginState == "wronglogin"){
$messages['wrongLogin'] = true;
}
}
include( Config::$templates.'login.tpl.php' );
}
else if( $r[0] == 'static' ) {
preg_match('/(\w+)/', $r[1], $m );
if( !empty($m[1]) && file_exists('static/'.$m[1].'.html.php') ) {
$user->loadEmail();
include( Config::$templates.'header.tpl.php' );
include( 'static/'.$m[1].'.html.php' );
include( Config::$templates.'footer.tpl.php' );
} else {
header( 'HTTP/1.0 404 Not Found' );
include( Config::$templates.'404.tpl.php' );
}
}
else if( $r[0] == 'logout' ) { //---------------------------------- logout
if( Config::$vbbIntegration['enabled'] ) { require_once( 'lib/class.forumops.php' ); }
$user->logout();
header( 'location: '.Config::$absolutePath );
exit();
}
else if( $r[0] == 'impressum' ){
include( Config::$templates.'header.tpl.php' );
include( Config::$templates.'impressum.tpl.php' );
include( Config::$templates.'footer.tpl.php' );
exit();
}
else if( $r[0] == 'chat' ){
include( Config::$templates.'header.tpl.php' );
include( Config::$templates.'chat.tpl.php' );
include( Config::$templates.'footer.tpl.php' );
exit();
}
else if( $r[0] == 'truhe' ){
include( Config::$templates.'header.tpl.php' );
include( Config::$templates.'truhe.tpl.php' );
include( Config::$templates.'footer.tpl.php' );
exit();
}
else if( $r[0] == 'forum' ){
include( Config::$templates.'header.tpl.php' );
include( Config::$templates.'forum.tpl.php' );
include( Config::$templates.'footer.tpl.php' );
exit();
}
else if( $r[0] == 'shop' ){
include( Config::$templates.'header.tpl.php' );
include( Config::$templates.'shop.tpl.php' );
include( Config::$templates.'footer.tpl.php' );
exit();
}else if( $r[0] == 'abuseform' ) {
include("templates/abuseform.tpl.php");
exit();
}else if( $r[0] == 'manage' ) { //---------------------------------- manage
if($user->admin){
if ($r[1] == 'del'){
DB::query("DELETE FROM pl_abuse WHERE id=:1",$r[2]);
header( 'location: '.Config::$absolutePath.'manage' );
}elseif ($r[1] == 'free'){
DB::updateRow("pl_users",array("id"=>$r[2]),array("spamblocked"=>0,"time"=>0));
header( 'location: '.Config::$absolutePath.'manage' );
}
include("templates/manage.tpl.php");
exit();
}else{
header( 'location: '.Config::$absolutePath );
exit();
}
}else if( $r[0] == 'invites' ) { //---------------------------------- invite
if($user->id){
include("templates/invites.tpl.php");
exit();
}else{
if(isset($r[1]) && validInvite($r[1])){
include("templates/register_invite.tpl.php");
exit();
}else{
header( 'location: '.Config::$absolutePath );
exit();
}
}
}else if( $r[0] == 'abuse' ) { //---------------------------------- abuse
$abuseerrors[] = array();
if (!empty($_POST["rsn"]) && !empty($_POST["mail"])){
if (!empty($_POST["imglink"])){
if(DB::insertRow("pl_abuse",array("reason" => $_POST["rsn"],"email" => $_POST["mail"],"read" => 0,"logged" => time(),"imagelink" => $_POST["imglink"],"user" => $user->id))){
$abuseerrors["abuse"] = "Abused.";
$abuseerrors["referer"] = $_SERVER['HTTP_REFERER'];
include("templates/abuse.tpl.php");
mail( "abuse@fuehls.com", "New Abuse | Link", "New Abuse: ". $_POST["imglink"].' - http://www.fuehls.com/manage', 'FROM: Abuse' );
exit;
}else{
$abuseerrors["abusefailed"] = "Abuse failed.";
$abuseerrors["referer"] = $_SERVER['HTTP_REFERER'];
include("templates/abuse.tpl.php");
exit;
}
}
if(DB::insertRow("pl_abuse",array("reason" => $_POST["rsn"],"email" => $_POST["mail"],"read" => 0,"logged" => time(),"imageid" => $_POST["image"],"user" => $user->id)) || preg_match( '/^[\.\w\-]{1,}@[\.\w\-]{2,}\.[\w]{2,}$/', $_POST['mail'])){
$abuseerrors["abuse"] = "Abused.";
$abuseerrors["referer"] = $_SERVER['HTTP_REFERER'];
include("templates/abuse.tpl.php");
mail( "abuse@fuehls.com", "New Abuse | Image", "New Abuse: ". $_POST["image"].' - http://www.fuehls.com/manage', 'FROM: Abuse' );
exit;
}else{
$abuseerrors["abusefailed"] = "Abuse failed.";
$abuseerrors["referer"] = $_SERVER['HTTP_REFERER'];
}
include("templates/abuse.tpl.php");
exit;
}else{
$abuseerrors["abusefailed"] = "Abuse failed.";
$abuseerrors["referer"] = $_SERVER['HTTP_REFERER'];
include("templates/abuse.tpl.php");
exit;
}
header( 'location: '.Config::$absolutePath );
exit();
}
else if( $r[0] == 'register' ) { //-------------------------------- new user
if( Config::$vbbIntegration['enabled'] ) { require_once( 'lib/class.forumops.php' ); }
if( $user->id ) {
header( 'location: '.Config::$absolutePath );
exit();
}
require_once('recaptchalib.php');
$privatekey = "6LfIwOYSAAAAAKnYTwQf3fCzQ4DtK--E6oFcEKkH";
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
$reg = DB::getRow("SELECT * FROM pl_settings");
$doubleacc = DB::getRow("SELECT COUNT(*) as c FROM pl_registerlock WHERE ip=:1",$_SERVER['REMOTE_ADDR']);
if(isset($_POST['invite'])){
$inviteCheck = validInvite($_POST['invite']);
}else{
$inviteCheck = false;
}
if(!$inviteCheck){
if ($reg["register"] != 1 || $doubleacc["c"] > 0){
include( Config::$templates.'register_closed.tpl.php' );
exit;
}
}
if($inviteCheck){
$invCode = $_POST['invite'];
}else{
$invCode = false;
}
if( isset($_POST['register']) && $resp->is_valid && $user->register( $messages,$invCode ) ) {
include( Config::$templates.'registered.tpl.php' );
} else {
if ( isset($_POST['register']) && !$resp->is_valid) {
$messages['captchaInc'] = true;
include( Config::$templates.'register.tpl.php' );
} else {
$messages['captchaInc'] = NULL;
include( Config::$templates.'register.tpl.php' );
}
}
}
else if( //----------------------------------------------------- view
($r[0] == 'all' && $r[1] == 'view') ||
( in_array($r[0], array('user', 'search')) && $r[2] == 'view')
) {
require_once( 'lib/imageviewer.php' );
$iv = new ImageViewer();
if( $r[0] == 'all' ) { // /all/view/2007/09/hans
$iv->setCurrent( $r[2].'/'.$r[3].'/'.$r[4] );
if ($r[1] == 'unfollow'){
DB::query("DELETE FROM pl_unread WHERE userid=:1 AND imageid=:2",$user->id,$iv->image["id"]);
}
if ($r[5] == "fav"){
if($user->id){
$imgId = DB::getRow("SELECT * FROM pl_images WHERE keyword=:1",$r[2].'/'.$r[3].'/'.$r[4]);
if (isset($imgId)){
$countfav = DB::getRow("SELECT COUNT( * ) AS c FROM pl_fav WHERE user=:1 and imageId=:2",$user->id,$imgId['id']);
if ((int)$countfav["c"] > 0){
DB::query("DELETE FROM pl_fav WHERE user=:1 and imageId =:2",$user->id,$imgId['id']);
DB::query("DELETE FROM pl_comments WHERE userId=:1 and imageId =:2 and c_like=1",$user->id,$imgId['id']);
DB::query("UPDATE pl_images SET score=score-5 WHERE id=:1",$imgId['id']);
$iv->setFav("remove");
}else{
DB::insertRow("pl_fav",array("imageId"=>$imgId['id'],"user"=>$user->id));
DB::query("UPDATE pl_images SET score=score+5 WHERE id=:1",$imgId['id']);
$datenow = date( 'Y.m.d H:i:s' );
DB::insertRow( "pl_comments", array(
'imageId' => $imgId['id'],
'userId' => $user->id,
'created' => $datenow,
'content' => "i like",
'c_like' =>1));
$iv->setFav("add");
}
}
}
}
}
else if( $r[0] == 'user' ) { // /user/name/view/2007/09/hans
$iv->setCurrent( $r[3].'/'.$r[4].'/'.$r[5] );
$iv->setUser( $r[1] );
if ($r[6] == "fav"){
$imgId = DB::getRow("SELECT * FROM pl_images WHERE keyword=:1",$r[3].'/'.$r[4].'/'.$r[5]);
if (isset($imgId)){
$countfav = DB::getRow("SELECT COUNT( * ) AS c FROM pl_fav WHERE user=:1 and imageId =:2",$user->id,$imgId['id']);
if ((int)$countfav["c"] > 0){
DB::query("DELETE FROM pl_fav WHERE user=:1 and imageId =:2",$user->id,$imgId['id']);
$iv->setFav("remove");
}else{
DB::insertRow("pl_fav",array("imageId"=>$imgId['id'],"user"=>$user->id));
$iv->setFav("add");
}
}
}
}
else if( $r[0] == 'search' ) { // /search/term/view/2007/09/hans
list( $term, $keyword ) = explode( '/view/', str_ireplace('search/', '', $query) );
$iv->setCurrent( $keyword );
$iv->setSearch( $term );
}
$iv->load();
$iv->grid = true;
// Add comment if we have one
include( 'lib/imageuploader.php' );
if( $_POST['addComment'] && $iv->addComment($user->id, $_POST['content'],$_FILES['image_comment']['name']) ) {
$uploadid= DB::getRow("SELECT LAST_INSERT_ID() as id");
if(
((!empty($_FILES['image_comment']['name']) && ImageUploader::process($_FILES['image_comment']['name'], $_FILES['image_comment']['tmp_name'], "", true, $uploadErrors,"",true,$uploadid["id"])))
||
((!empty($_POST['url_comment']) && ImageUploader::copyFromUrl( $_POST['url_comment'], "", true, $uploadErrors,true,$uploadid["id"])))
){
header( 'Location: '.Config::$absolutePath.$iv->basePath.'view/'.$iv->image['keyword'] );
}else{
header( 'Location: '.Config::$absolutePath.$iv->basePath.'view/'.$iv->image['keyword'] );
exit();
}
}else{
}
if( !empty($iv->image['id']) ) {
$iv->loadComments();
$counter = DB::getRow("SELECT COUNT(*) as c FROM pl_unread WHERE userid=:1 AND imageid=:2",$user->id,$iv->image["id"]);
if (($counter["c"] != 0)){
DB::query("DELETE FROM pl_unread WHERE userid=:1 AND imageid=:2",$user->id,$iv->image["id"]);
}
//$cache->capture();
include( Config::$templates.'view.tpl.php' );
} else {
header( 'HTTP/1.0 404 Not Found' );
include( Config::$templates.'404.tpl.php' );
}
}
else if( //----------------------------------------------------- browse
empty($r[0]) ||
in_array( $r[0], array('all', 'user', 'search','comments','fame','abuse','unread',"favorites","invites") )
) {
require_once( 'lib/imagebrowser.php' );
$ib = new ImageBrowser( Config::$images['thumbsPerPage'] );
if( empty($r[0]) || $r[0] == 'all' ) { // /all/page/2
$ib->setPage( $r[2] );
}
else if( $r[0] == 'user' ) { // /user/name/page/2
$ib->setPage( $r[3] );
$ib->setUser( $r[1] );
}
else if( $r[0] == 'comments' ) { // /comments
if ($r[1] == 'reset'){
DB::query("DELETE FROM pl_unread WHERE userid=:1",$user->id);
}
if(!empty($user->id)){
$ib->setPage( $r[2] );
$ib->setComment(true,false);
$ib->setuserID( $user->id );}else{ header( 'location: '.Config::$absolutePath.'login' );}
}
else if( $r[0] == 'favorites' ) { // /fav
if(!empty($user->id)){
$ib->setPage( $r[2] );
$ib->setFav(true);
$ib->setuserID( $user->id );}else{ header( 'location: '.Config::$absolutePath.'login' );}
}
else if( $r[0] == 'unread' ) { // /unread
if ($r[1] == 'reset'){
DB::query("DELETE FROM pl_unread WHERE userid=:1",$user->id);
}
$counter = DB::getRow("SELECT COUNT(*) as c FROM pl_unread WHERE userid=:1",$user->id);
$unreadBool = true;
if ($counter["c"] > 0){
if(!empty($user->id)){
$ib->setPage( $r[2] );
$ib->setComment(true,true);
$ib->setuserID( $user->id );}else{ header( 'location: '.Config::$absolutePath.'login' );}
}else{
header( 'location: '.Config::$absolutePath.'comments' );
}
}
else if( $r[0] == 'search' ) { // /search/term/page/2
list( $term, $page ) = explode( '/page/', str_ireplace('search/', '', $query) );
$ib->setPage( $page );
$ib->setSearch( $term );
}else if( $r[0] == 'fame' ) {
include( Config::$templates.'fame.tpl.php' );
exit();
}
$ib->load();
if( !empty($ib->thumbs) ) {
require_once( 'lib/gridview.php' );
$gv = new GridView( Config::$gridView['gridWidth'] );
$gv->solve( $ib->thumbs );
//$cache->capture();
include( Config::$templates.'browse.tpl.php' );
} else {
if($unreadBool) {
DB::getRow("DELETE FROM pl_unread WHERE userid=:1",$user->id);
header( 'location: '.Config::$absolutePath.'comments' );}
include( Config::$templates.'404.tpl.php' );
}
}
else if( $r[0] == 'random' ) {
$count = max( 1, min( Config::$maxRandomThumbs, intval($r[1]) ) );
$size = '';
foreach( Config::$gridView['classes'] as $c ) {
if( $r[2] == $c['dir'] ) {
$size = $r[2];
break;
}
if( empty($size) ) {
$size = $c['dir'];
}
}
require_once( 'lib/imagebrowser.php' );
$ib = new ImageBrowser( $count );
$ib->loadRandom( Config::$minRandomScore, $size );
//$cache->forceEnable();
//$cache->capture();
include( Config::$templates.'random.js.php' );
}
else if( $r[0] == 'upload' ) {
/*if( $user->id ) {
$uploadErrors = array();
if( $user->isSpamLocked() ) {
$uploadErrors[] = 'No more than 50 images in 2 hours!';
}
if( $user->isSpamming() ) {
$uploadErrors[] = 'Spamming ist nicht erlaubt. Wende dich an einen Administrator';
}
if( $user->isSpamer() ) {
$uploadErrors[]='You have to wait 10 Seconds.';
}
*/
if( $user->id ) {
$uploadErrors = array();
$spaming = $user->isSpamming();
if( $user->isSpamer()) {
$uploadErrors[]='You have to wait 10 Seconds.';
}elseif (is_numeric($spaming)){
if( (int)$spaming > 0 ){
$blockreason = DB::getRow("SELECT * FROM pl_users WHERE id=:1",$user->id);
$uploadErrors[] = 'Upload gesperrt bis: '.date('Y-m-d H:i:s',(int)$blockreason["time"]);
$uploadErrors[] = 'Grund: '.$blockreason["spam_reason"];
$left = ((int)$blockreason["time"] - (int)time())/60;
$uploadErrors[] = 'Noch: '.round($left,2).' Minuten ';
}
}elseif( $user->isSpamming() ) {
$uploadErrors[] = 'Spamming ist nicht erlaubt. Wende dich an einen Administrator <br> <br> Mann: <a href="/inbox/Mann"><img src="/media/mail.png"></a>';
$uploadErrors[] = string(is_numeric($user->isSpamming()));
}elseif( $user->isSpamLocked() ) {
$uploadErrors[] = 'No more than 50 images in 2 hours!';
}elseif( !empty( $_POST ) ) {
require_once( 'lib/imageuploader.php' );
if(
(!empty($_POST['url']) && ImageUploader::copyFromUrl( $_POST['url'], $_POST['tags'], false, $uploadErrors,false,0)) ||
( !empty($_FILES['image']['name']) && ImageUploader::process($_FILES['image']['name'], $_FILES['image']['tmp_name'], $_POST['tags'], true, $uploadErrors,'',false,0)
)
) {
//$cache->clear();
if (!empty($_POST['ucomment'])){
$imgid= DB::getRow("SELECT LAST_INSERT_ID() as id");
$datenow = date( 'Y.m.d H:i:s' );
DB::insertRow( TABLE_COMMENTS, array(
'imageId' => $imgid["id"],
'userId' => $user->id,
'created' => $datenow,
'content' => $_POST['ucomment'],
'thumb' =>0));
}
$user->logUpload();
header( "Location: ".Config::$absolutePath );
exit(0);
}
}
//bei fehler
require_once( 'lib/imagebrowser.php' );
$ib = new ImageBrowser( Config::$images['thumbsPerPage'] );
$ib->load();
if( !empty($ib->thumbs) ) {
require_once( 'lib/gridview.php' );
$gv = new GridView( Config::$gridView['gridWidth'] );
$gv->solve( $ib->thumbs );
//$cache->capture();
include( Config::$templates.'browse.tpl.php' );
} else {
if($unreadBool) {
DB::getRow("DELETE FROM pl_unread WHERE userid=:1",$user->id);
header( 'location: '.Config::$absolutePath.'comments' );}
include( Config::$templates.'404.tpl.php' );
}
} else {
header( 'location: '.Config::$absolutePath.'login' );
}
}
else if( $r[0] == 'profile' ) {
if( $user->id ) {
if( Config::$vbbIntegration['enabled'] ) { require_once( 'lib/class.forumops.php' ); }
$messages = array();
if( !empty( $_POST ) ) {
$user->profile( $_FILES['avatar']['tmp_name'], $messages );
if( empty( $messages ) ) {
header( 'location: '.Config::$absolutePath );
}
}
$user->loadEmail();
include( Config::$templates.'profile.tpl.php' );
} else {
header( 'location: '.Config::$absolutePath.'login' );
}
}
else if( $r[0] == 'users' ) {
require_once( 'lib/userlist.php' );
$ul = new UserList( Config::$usersPerPage );
$ul->setPage( $r[2] );
$ul->load();
// //$cache->capture();
include( Config::$templates.'userlist.tpl.php' );
}
else if( $r[0] == 'quicktags' ) { //------------------------------------------- quicktagger
if( $user->id ) {
include( Config::$templates.'quicktags.tpl.php' );
} else {
header( 'location: '.Config::$absolutePath.'login' );
}
}
else if( $r[0] == 'inbox' ){
//$user = new User();
$msgErrors[] = array();
if( $user->id ) {
if (isset($r[1])){
if( preg_match('/^\w{2,20}$/', $r[1]) ) {
if ((isset($_POST["content"]) || isset($_POST["title"]))){
$usercount = DB::getRow('SELECT COUNT(*) as c, id FROM pl_users WHERE name LIKE "'.$r[1].'"');
$blockedrow = DB::getRow("SELECT id,users FROM pl_blocked WHERE id=:1",$usercount["id"]);
$blockeduser = array_map('strtolower', unserialize($blockedrow['users']));
$lower = strtolower($user->name);
if (in_array($lower,$blockeduser)){
$msgErrors["userblocked"] = true;
include( Config::$templates.'inbox.tpl.php' );
exit();
}
if ($usercount["c"] == 0){
$msgErrors["usernotfound"] = true;
include( Config::$templates.'inbox.tpl.php' );
}else{
DB::insertRow( "pl_messages", array(
'from_m' => $user->id,
'to_m' => $usercount["id"],
'created' => time(),
'message_m' => $_POST["content"],
'title_m' => $_POST["title"]));
header( 'location: '.Config::$absolutePath."inbox/".$r[1]);
}
}else{
include( Config::$templates.'inboxuser.tpl.php' );}
}else{
header( 'location: '.Config::$absolutePath);}
}else{
include( Config::$templates.'inbox.tpl.php' );
}
} else {
header( 'location: '.Config::$absolutePath.'login' );
}
}
else { //------------------------------------------------------- 404
header( 'HTTP/1.0 404 Not Found' );
include( Config::$templates.'404.tpl.php' );
//$cache->disable();
}
//$cache->write();
?>