forked from 4ducky/4ducky
Move the original PHP site into legacy/
The PHP sources, templates and old jQuery-based scripts move unchanged into legacy/ for reference. Shared assets (media/, images/, favicon.ico, the default avatar) stay at the repository root. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,341 @@
|
||||
<?php
|
||||
header("Content-type: text/html; charset=UTF-8");
|
||||
function shorter($input, $length)
|
||||
{
|
||||
//no need to trim, already shorter than trim length
|
||||
if (strlen($input) <= $length) {
|
||||
return $input;
|
||||
}
|
||||
|
||||
//find last space within length
|
||||
$last_space = strrpos(substr($input, 0, $length), ' ');
|
||||
if(!$last_space) $last_space = $length;
|
||||
$trimmed_text = substr($input, 0, $last_space);
|
||||
|
||||
//add ellipses (...)
|
||||
$trimmed_text .= '...';
|
||||
|
||||
return $trimmed_text;
|
||||
}
|
||||
|
||||
function howlong($a=0, $b=0) {
|
||||
if (!is_numeric($a)) $a = strtotime($a); if (!is_numeric($b)) $b = strtotime($b);
|
||||
if ($a == 0) $a = time(); if ($b == 0) $b = time();
|
||||
if ($a == $b) return "at the same time";
|
||||
if ($a > $b) { $aa = $b; $b = $a; $a = $aa; $q = "away"; } else { $q = "ago"; }
|
||||
$value = $b-$a;
|
||||
if ($value == 1) return "1 second $q";
|
||||
if ($value < 60) return "$value seconds $q";
|
||||
$value /= 60;
|
||||
if (round($value) == 1) return "1 minute $q";
|
||||
if ($value < 60) return round($value) . " minutes $q";
|
||||
$value /= 60;
|
||||
if (round($value) == 1) return "1 hour $q";
|
||||
if ($value < 24) return round($value) . " hours $q";
|
||||
$value /= 24;
|
||||
if (round($value) == 1) if ($q == "ago") return "yesterday"; else return "tomorrow";
|
||||
if ($value < 31) return round($value) . " days $q";
|
||||
$value /= 31;
|
||||
if (round($value) == 1) return "1 month $q";
|
||||
if ($value < 12) return round($value) . " months $q";
|
||||
$value /= 12;
|
||||
if (round($value) == 1) return "1 year $q";
|
||||
return round($value) . " years $q";
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && (strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest')) {
|
||||
|
||||
|
||||
$libpath = 'lib';
|
||||
include( $libpath.'/config.php' );
|
||||
include( $libpath.'/db.php' );
|
||||
include( $libpath.'/users.php' );
|
||||
|
||||
|
||||
if((empty($_COOKIE[Config::$sessionCookie]) && !empty($_COOKIE[Config::$rememberCookie]))) {
|
||||
if( Config::$vbbIntegration['enabled'] ) { include( 'lib/class.forumops.php' ); }
|
||||
}
|
||||
|
||||
$user = new User();
|
||||
$messages = array();
|
||||
$LoginState = $user->login();
|
||||
|
||||
if ( $_POST["q"] == "lastcomments"){
|
||||
|
||||
$comments = DB::query("SELECT
|
||||
c.created, i.keyword,c.id,u.name,u.avatar,c.content
|
||||
FROM pl_comments c
|
||||
LEFT JOIN pl_users u ON c.userId = u.id
|
||||
RIGHT JOIN pl_images i ON c.imageId = i.id
|
||||
WHERE c.c_like=0 ORDER BY c.created DESC
|
||||
LIMIT 30");
|
||||
|
||||
foreach (array_keys($comments) as $c) {
|
||||
$blockedrow = DB::getRow("SELECT id,users FROM pl_blocked WHERE id=:1",$user->id);
|
||||
$blockeduser = array_map('strtolower', unserialize($blockedrow['users']));
|
||||
$lower = strtolower($comments[$c]["name"]);
|
||||
|
||||
if (!in_array($lower,$blockeduser)){
|
||||
?>
|
||||
|
||||
<div id="commentbar">
|
||||
|
||||
<a href="<?php echo (Config::$absolutePath.'all/view/'.$comments[$c]["keyword"]); ?>">
|
||||
<div id="commentimg">
|
||||
<img width="28" height="28" src="<?php echo(Config::$absolutePath.$comments[$c]["avatar"]); ?>" />
|
||||
</div>
|
||||
<div id="commenttext">
|
||||
<strong><?php echo(shorter(strip_tags($comments[$c]["name"]),"10")); ?>: </strong><?php echo(shorter(strip_tags($comments[$c]["content"]),"50")); ?>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<?php }}
|
||||
|
||||
|
||||
|
||||
}elseif($_POST["q"] == "comments" && isset($_POST["imageId"])){
|
||||
|
||||
$comments = DB::query(
|
||||
'SELECT
|
||||
c.id,c.c_like,c.userId, c.content, u.name, u.avatar, u.color,
|
||||
UNIX_TIMESTAMP(c.created) AS created
|
||||
FROM '.TABLE_COMMENTS.' c
|
||||
LEFT JOIN '.TABLE_USERS.' u
|
||||
ON u.id = c.userId
|
||||
WHERE c.imageId = :1
|
||||
ORDER BY c_like DESC,created',
|
||||
$_POST["imageId"]
|
||||
);
|
||||
|
||||
$commentCount = count( $comments );
|
||||
$likeCount = 0;
|
||||
?>
|
||||
|
||||
<?php
|
||||
require_once 'lib/bbcode.class.php';
|
||||
$bbcode = new SimpleBBCode;
|
||||
|
||||
foreach( array_keys($comments) as $i ) {
|
||||
$comments[$i]['content'] = nl2br($bbcode->parse(
|
||||
htmlspecialchars($comments[$i]['content']))
|
||||
);
|
||||
}
|
||||
|
||||
foreach( $comments as $c ) {
|
||||
|
||||
$commentimg = DB::getRow("SELECT * FROM pl_commentuploads WHERE c_id=:1",$c['id']);
|
||||
|
||||
if (count($commentimg) != 0){
|
||||
$min = 'style="min-height:86px;"';
|
||||
}else{
|
||||
$min = '';
|
||||
}
|
||||
$cst = "";
|
||||
if ($c["color"] != "000000"){
|
||||
$cst = 'style="color:#'.$c["color"].'"';
|
||||
}
|
||||
|
||||
$blockedrow = DB::getRow("SELECT id,users FROM pl_blocked WHERE id=:1",$user->id);
|
||||
$blockeduser = array_map('strtolower', unserialize($blockedrow['users']));
|
||||
$lower = strtolower($c['name']);
|
||||
|
||||
|
||||
if((int)$c["c_like"] ==1 && $likeCount ==0){ ?>
|
||||
|
||||
<div class="comment" style="border: 1px solid #FFD600;">
|
||||
<div style="color: #FFD600;font-size: 30px;width:32px;height:32px; float: left; padding-left: 7px;">♥</div>
|
||||
|
||||
<?php foreach( $comments as $c ) {
|
||||
if((int)$c["c_like"] ==1){ ?>
|
||||
<a title="ID: <?php echo $c["userId"]; ?>" href="<?php echo Config::$absolutePath.'user/'.$c['name']; ?>"><img class="avatarSmall" width="32" height="32" src="<?php echo Config::$absolutePath.$c['avatar']; ?>"/></a> <?php }
|
||||
} $likeCount = 1;?>
|
||||
</div>
|
||||
|
||||
<?php }else{
|
||||
if (in_array($lower,$blockeduser)){
|
||||
?>
|
||||
<br/><a class="quote" style="margin-left: 5px;" href="javascript:;" onclick="javascript:toggle('comment<?php echo $c['id'];?>');"><img style="margin-right: 10px; vertical-align:middle;" height="28" width="28" src="/media/xd.png" alt="blocked"/>Comment blocked (<?php echo($c['name'])?>)</a>
|
||||
<div style="display: none;" id="comment<?php echo $c['id'];?>">
|
||||
<?php }
|
||||
|
||||
if((int)$c["c_like"] ==0){
|
||||
?>
|
||||
|
||||
|
||||
<div id="comment<?php echo $c['id']; ?>" class="comment" <?php echo($min); ?>>
|
||||
<table width="100%" border="0" cellspacing="0" cellpadding="0">
|
||||
<tr>
|
||||
<td width="40" valign="top"><a <?php echo($cst); ?> title="ID: <?php echo $c["userId"]; ?>" href="<?php echo Config::$absolutePath.'user/'.$c['name']; ?>"><img class="avatarSmall" width="32" height="32" src="<?php echo Config::$absolutePath.$c['avatar']; ?>"/></a></td>
|
||||
<td valign="top" >
|
||||
<div class="info" id="unmark" style="float:right;padding-right:5px;"><a href="#content_comment" class="quote" onclick="reComment(<?php echo $c['id']; ?>,'<?php echo $c['name']; ?>')"><?php echo howlong($c['created'],time()); ?></a> <?php if ($user->admin) { ?><a href="javascript:;" onclick="return delComment(<?php echo $c['id']; ?>, this)">[x]</a><?php } ?></div><div><a <?php echo($cst); ?> title="ID: <?php echo $c["userId"]; ?>" href="<?php echo Config::$absolutePath.'user/'.$c['name']; ?>"><?php echo $c['name']; ?></a></div>
|
||||
<?php if(isset($commentimg)) {?>
|
||||
<div style="float:left;margin-right:10px;"><a href="<?php echo(Config::$absolutePath.$commentimg['image_link']); ?>" rel="lightbox[more]" title="<?php echo $c["content"];?>"><img src="<?php echo(Config::$absolutePath.$commentimg["thumb_link"]); ?>"/></a>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<div id="<?php echo $c['id']; ?>"><?php echo $c["content"];?></div></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<?php } if (in_array($lower,$blockeduser)){ echo("</div>"); }}
|
||||
|
||||
}
|
||||
if(!isset($comments)){
|
||||
echo "no comments yet";
|
||||
}
|
||||
|
||||
}elseif($_POST["q"] == "add" && isset($_POST["imageId"]) && isset($_POST["content"])){
|
||||
if($user->id){
|
||||
|
||||
require_once( 'lib/imageviewer.php' );
|
||||
$iv = new ImageViewer();
|
||||
$keyword = DB::getRow("SELECT keyword FROM pl_images WHERE id=:1",$_POST["imageId"]);
|
||||
$iv->setCurrent($keyword["keyword"]);
|
||||
$iv->load();
|
||||
|
||||
if($iv->addComment($user->id, $_POST['content'],$_POST["urlUpload"]) ) {
|
||||
$uploadid= DB::getRow("SELECT LAST_INSERT_ID() as id");
|
||||
|
||||
if (strlen($_POST["urlUpload"]) > 4){
|
||||
include( 'lib/imageuploader.php' );
|
||||
if(ImageUploader::copyFromUrl( $_POST["urlUpload"], "", true, $uploadErrors,true,$uploadid["id"])){
|
||||
|
||||
}else{echo("notok-image");exit();}
|
||||
}
|
||||
|
||||
}else{echo("notok-comment");exit();}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}elseif($_POST["q"] == "fav" && isset($_POST["imageId"])){
|
||||
if($user->id){
|
||||
$imgId = DB::getRow("SELECT * FROM pl_images WHERE id=:1",$_POST["imageId"]);
|
||||
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']);
|
||||
echo("Removed from your favorites");
|
||||
}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));
|
||||
|
||||
echo("Added to your favorites");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}elseif($_POST["q"] == "upload"){
|
||||
$uploadErrors = array();
|
||||
if( $user->id ) {
|
||||
|
||||
$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. Wennde 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!';
|
||||
}
|
||||
}else{
|
||||
$uploadErrors[] = 'Log in.';
|
||||
}
|
||||
|
||||
if(count($uploadErrors) > 0){
|
||||
|
||||
?>
|
||||
|
||||
<ul>
|
||||
<?php foreach($uploadErrors as $e){ ?>
|
||||
<li><?php echo $e; ?></li>
|
||||
<?php }?>
|
||||
</ul>
|
||||
|
||||
|
||||
<?php
|
||||
|
||||
|
||||
|
||||
}else{?>
|
||||
|
||||
|
||||
<form id="UForm" action="/upload" method="post" enctype="multipart/form-data" >
|
||||
<table width="80%" border="0" cellspacing="1px" cellpadding="0">
|
||||
<tr>
|
||||
<td valign="top"><strong>Rules:</strong></td>
|
||||
<td style="padding-left:3px;" valign="top">Gore, CP, Spam, Nazi, Porn = Ban <br /><br />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top"><strong>Image:</strong></td>
|
||||
<td valign="top"><input type="file" name="image" style="color: #000; background-color: #fff;"/><br /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top"><strong>or Url:</strong></td>
|
||||
<td valign="top"><input type="text" name="url" value=""/><br /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top"><strong>Comment:</strong></td>
|
||||
<td valign="top"><textarea id="content_comment" name="ucomment" rows="3" cols="30"></textarea><br /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td align="right"><input type="submit" name="upload" value="Upload" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
<input type="hidden" id="q" value="upload" />
|
||||
</form>
|
||||
|
||||
|
||||
<?php }
|
||||
|
||||
|
||||
|
||||
}elseif($_POST["q"] == "addon"){
|
||||
|
||||
?>
|
||||
|
||||
<p>
|
||||
To use the remote upload just drag the following link somewhere to your bookmarks (or in Opera right click it
|
||||
and choose <em>Bookmark link</em>):
|
||||
» <a onclick="alert('Drag this Link to your Bookmarks!'); return false;" href="javascript:void((function(){var%20e=document.createElement('script');e.setAttribute('type','text/javascript');e.setAttribute('src','<?php echo Config::$frontendPath; ?>media/post.js.php');document.body.appendChild(e)})());"><u>Post to <?php echo Config::$siteName ?></u></a> «
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Now, if you're on a website where you see an image you want to post, just click on your newly created bookmark
|
||||
and then on the image you want to post. Thats all. Really!
|
||||
</p>
|
||||
|
||||
<?php
|
||||
|
||||
}else{
|
||||
|
||||
echo"Error";
|
||||
|
||||
}
|
||||
}else{
|
||||
echo"Error";
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user