Browse Source

Merge branch 'development'

tags/v1.3
Teknikode 6 years ago
parent
commit
5717b6ab5c

+ 16
- 3
includes/common.php View File

@@ -186,8 +186,21 @@ function upload($files, $CONF, $db)
{
$iv = rand_string(32);
$targetFile = upload_file($files, $CONF['upload_dir'], $CONF['key'], $iv, $CONF['cipher']);
$file_used = true;
while ($file_used)
{
$randomString = rand_string(6);
$fileURL = $randomString;
$result = $db->select("uploads", "url=?", array($fileURL));
if (!$result)
{
$file_used = false;
}
}
$data = array(
"filename" => $targetFile,
"url" => $fileURL,
"type" => $file_type,
"user_id" => $user_id,
"upload_date" => date("Y-m-d H:i:s",time()),
@@ -196,8 +209,8 @@ function upload($files, $CONF, $db)
"cipher" => $CONF['cipher']
);
$db->insert($data, 'uploads');
$_SESSION[$targetFile] = $targetFile;
return array('results' => array('file' => array('name' => $targetFile, 'url' => get_page_url("u", $CONF).'/'.$targetFile, 'type' => $file_type, 'size' => $filesize)));
$_SESSION[$fileURL] = $fileURL;
return array('results' => array('file' => array('name' => $fileURL, 'url' => get_page_url("u", $CONF).'/'.$fileURL, 'type' => $file_type, 'size' => $filesize)));
}
return array('error' => $CONF['errors']['InvFile']);
}
@@ -212,7 +225,7 @@ function upload_file($file, $destination, $key, $iv, $cipher)
$file_used = true;
while ($file_used)
{
$randomString = rand_string(6);
$randomString = rand_string(12);
$targetFile = $randomString.'.'.$fileType;
if (!file_exists($destination.$targetFile))
{

+ 3
- 0
templates/default/footer.php View File

@@ -8,6 +8,9 @@
<!-- Piwik -->
<script type="text/javascript">
var _paq = _paq || [];
_paq.push(["setDocumentTitle", document.domain + "/" + document.title]);
_paq.push(["setCookieDomain", "*.teknik.io"]);
_paq.push(["setDomains", ["*.teknik.io"]]);
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {

+ 1
- 0
templates/default/header.php View File

@@ -115,6 +115,7 @@
case "walls":
array_push($cssFiles, 'blueimp-gallery.min.css', 'bootstrap-image-gallery.min.css');
array_push($jsFiles,
'blueimp/blueimp-gallery.min.js',
'jquery/jquery.blueimp-gallery.min.js',
'bootstrap/image-gallery/bootstrap-image-gallery.min.js',
'walls.js');

BIN
templates/default/img/error.png View File


+ 5
- 0
templates/default/img/error.svg View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="64" height="64">
<circle cx="32" cy="32" r="25" stroke="red" stroke-width="7" fill="black" fill-opacity="0.2"/>
<rect x="28" y="7" width="8" height="50" fill="red" transform="rotate(45, 32, 32)"/>
</svg>

BIN
templates/default/img/play-pause.png View File


+ 6
- 0
templates/default/img/play-pause.svg View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="30" height="15">
<polygon points="2,1 2,14 13,7" stroke="black" stroke-width="1" fill="white"/>
<rect x="17" y="2" width="4" height="11" stroke="black" stroke-width="1" fill="white"/>
<rect x="24" y="2" width="4" height="11" stroke="black" stroke-width="1" fill="white"/>
</svg>

BIN
templates/default/img/video-play.png View File


+ 5
- 0
templates/default/img/video-play.svg View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="64" height="64">
<circle cx="32" cy="32" r="25" stroke="white" stroke-width="7" fill="black" fill-opacity="0.2"/>
<polygon points="26,22 26,42 43,32" fill="white"/>
</svg>

+ 2
- 0
templates/default/js/blueimp/blueimp-gallery.min.js
File diff suppressed because it is too large
View File


+ 45
- 0
templates/default/js/walls.js View File

@@ -0,0 +1,45 @@
/* global blueimp, $ */
$(function () {
'use strict';
// Load demo images from flickr:
$.ajax({
// Flickr API is SSL only:
// https://code.flickr.net/2014/04/30/flickr-api-going-ssl-only-on-june-27th-2014/
url: 'https://api.flickr.com/services/rest/',
data: {
format: 'json',
method: 'flickr.interestingness.getList',
api_key: '7617adae70159d09ba78cfec73c13be3' // jshint ignore:line
},
dataType: 'jsonp',
jsonp: 'jsoncallback'
}).done(function (result) {
var carouselLinks = [],
linksContainer = $('#links'),
baseUrl;
// Add the demo images as links with thumbnails to the page:
$.each(result.photos.photo, function (index, photo) {
baseUrl = 'https://farm' + photo.farm + '.static.flickr.com/' +
photo.server + '/' + photo.id + '_' + photo.secret;
$('<a/>')
.append($('<img>').prop('src', baseUrl + '_s.jpg'))
.prop('href', baseUrl + '_b.jpg')
.prop('title', photo.title)
.attr('data-gallery', '')
.appendTo(linksContainer);
carouselLinks.push({
href: baseUrl + '_c.jpg',
title: photo.title
});
});
// Initialize the Gallery as image carousel:
blueimp.Gallery(carouselLinks, {
container: '#blueimp-image-carousel',
carousel: true
});
});
});

+ 3
- 2
upload/delete_upload.php View File

@@ -7,7 +7,7 @@ if(isset($_GET))
{
$file = rawurldecode($_GET['file']);
$hash = rawurldecode($_GET['hash']);
$upload = $db->select('uploads', "filename=? LIMIT 1", array($file));
$upload = $db->select('uploads', "url=? LIMIT 1", array($file));
if ($upload)
{
$success = true;
@@ -20,12 +20,13 @@ if(isset($_GET))
if ($success)
{
$db->delete('uploads', 'id=?', array($upload['id']));
unlink($CONF['upload_dir'].$upload['filename']);
include('../templates/'.$CONF['template'].'/header.php');
?>
<div class="container">
<div class="row">
<div class="col-sm-12 text-center">
<h2><b><?php echo $upload['filename']; ?></b> has been successfully deleted.</h2>
<h2><b><?php echo $upload['url']; ?></b> has been successfully deleted.</h2>
</div>
</div>
</div>

+ 6
- 6
upload/generate_delete_link.php View File

@@ -3,20 +3,20 @@ include('../includes/config.php');
if(isset($_POST) && isset($_SESSION))
{
$filename = rawurldecode($_POST['uploadID']);
if (isset($_SESSION[$filename]) && $_SESSION[$filename] == $filename)
$file = rawurldecode($_POST['uploadID']);
if (isset($_SESSION[$file]) && $_SESSION[$file] == $file)
{
$file_db = $db->select('uploads', "filename=? LIMIT 1", array($filename));
$file_db = $db->select('uploads', "url=? LIMIT 1", array($file));
if ($file_db)
{
$delete_key = generate_code($file_db['filename'], $CONF);
$delete_key = generate_code($file_db['url'], $CONF);
$data = array(
"delete_key" => $delete_key
);
$post_id = $db->update($data, 'uploads', 'filename=?', array($filename));
$post_id = $db->update($data, 'uploads', 'url=?', array($file));
unset($_POST);
echo json_encode(array('result' => array('url' => get_page_url("u", $CONF).'/'.$file_db['filename'].'/'.$delete_key)));
echo json_encode(array('result' => array('url' => get_page_url("u", $CONF).'/'.$file_db['url'].'/'.$delete_key)));
}
else
{

+ 5
- 6
upload/lib/download.php View File

@@ -1,10 +1,9 @@
<?php
include('../../includes/config.php');
$path_parts = pathinfo($_GET['file']);
$file_name = $path_parts['basename'];
$file_path = $CONF['upload_dir'] . $file_name;
$file_db = $db->select('uploads', "filename=? LIMIT 1", array($file_name));
$temp_path = sys_get_temp_dir()."\\".$file_name;
$fileURL = $_GET['file'];
$file_db = $db->select('uploads', "url=? LIMIT 1", array($fileURL));
$file_path = $CONF['upload_dir'] . $file_db['filename'];
$temp_path = sys_get_temp_dir()."\\".$file_db['filename'];
if (file_exists($file_path) && $file_db)
{
@@ -21,7 +20,7 @@ if (file_exists($file_path) && $file_db)
$pattern = "/^((image)|(text)|(audio)|(video))\/(.*)$/";
if(!preg_match($pattern, $file_type))
{
header("Content-Disposition: attachment; filename=\"$file_name\"");
header("Content-Disposition: attachment; filename=\"".$file_db['filename']."\"");
header("Pragma: public");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header('Content-Type: '.$file_type);

+ 7
- 8
upload/main.php View File

@@ -54,27 +54,26 @@ Dropzone.options.TeknikUpload = {
});
this.on("success", function(file, responseText) {
obj = JSON.parse(responseText);
var full_name = obj.results.file.name;
var short_name = file.name.split(".")[0];
var name = obj.results.file.name;
$("#upload-links").css('display', 'inline', 'important');
$("#upload-links").prepend(' \
<div class="row link_'+short_name+'"> \
<div class="row link_'+name+'"> \
<div class="col-sm-6"> \
'+file.name+' \
</div> \
<div class="col-sm-3"> \
<a href="<?php echo get_page_url('u', $CONF); ?>/'+full_name+'" target="_blank" class="alert-link"><?php echo get_page_url('u', $CONF); ?>/'+full_name+'</a> \
<a href="<?php echo get_page_url('u', $CONF); ?>/'+name+'" target="_blank" class="alert-link"><?php echo get_page_url('u', $CONF); ?>/'+name+'</a> \
</div> \
<div class="col-sm-3"> \
<button type="button" class="btn btn-default btn-xs generate-delete-link-'+short_name+'" id="'+full_name+'">Generate Deletion URL</button> \
<button type="button" class="btn btn-default btn-xs generate-delete-link-'+name+'" id="'+name+'">Generate Deletion URL</button> \
</div> \
</div> \
');
linkUploadDelete('.generate-delete-link-'+short_name+'');
linkUploadDelete('.generate-delete-link-'+name+'');
});
this.on("removedfile", function(file) {
var short_name = file.name.split(".")[0];
$('.link_'+short_name).remove();
var name = file.name;
$('.link_'+name).remove();
});
this.on("reset", function(file, responseText) {
$("#upload_message").css('display', 'inline', 'important');

+ 63
- 0
walls/add_image.php View File

@@ -0,0 +1,63 @@
<?php
include('../includes/config.php');
$filename = "";
if(isset($_POST) && $logged_in)
{
//retrieve the $_POST variables
$filename_orig = rawurldecode($_POST['file_orig']);
$filename = rawurldecode($_POST['file']);
$title = rawurldecode($_POST['title']);
if ($title == "")
{
$title = $filename_orig;
}
$file_path = $CONF['upload_dir'] . $filename;
$thumbnail_path = $CONF['upload_dir'] . 'thumbnails/75_75_' . $filename;
$file_db = $db->select('uploads', "filename=? LIMIT 1", array($filename));
$temp_path = sys_get_temp_dir()."\\".$filename;
if (file_exists($file_path) && $file_db)
{
if ($file_db['hash'] != "")
{
$crypt = new Cryptography();
$result = $crypt->Decrypt($CONF['key'], $file_db['hash'], $file_path, $temp_path, $file_db['cipher']);
$file_path = $temp_path;
}
$file_type = $file_db['type'];
$pattern = "/^(image)\/(.*)$/";
if(preg_match($pattern, $file_type))
{
$resizeObj = new resize($file_path);
// *** 2) Resize image (options: exact, portrait, landscape, auto, crop)
$resizeObj->resizeImage(75, 75, 'landscape');
$resizeObj->saveImage($thumbnail_path, 70);
$data = array(
"user_id" => $user->id,
"title" => $title,
"src" => $filename,
"thumb" => $thumbnail_path,
"date_added" => date("Y-m-d H:i:s",time())
);
$row_id = $db->insert($data, 'walls');
$data = array(
"table_name" => 'walls',
"row_id" => $row_id,
"user_id" => $user->id,
"points" => 1
);
$db->insert($data, 'votes');
echo "true";
}
else
{
echo "Please upload an actual image.";
}
}
else
{
echo "No File Found";
}
}
?>

+ 40
- 0
walls/delete_image.php View File

@@ -0,0 +1,40 @@
<?php
require_once('../includes/config.php');
//check to see that the form has been submitted
$id = 0;
if(isset($_POST) && $logged_in)
{
$id = rawurldecode($_POST['id']);
$image = $db->select('walla', "id=? LIMIT 1", array($id));
if ($image)
{
$success = true;
$userID = $image['user_id'];
if($success && $user->id != $userID)
{
$error = "You are not allowed to delete this image.";
$success = false;
}
if ($success)
{
$db->delete('walls', 'id=?', array($id));
$db->delete('votes', 'row_id=? AND table_name=?', array($id, 'walls'));
echo "true";
}
else
{
echo $error;
}
}
else
{
echo "That image does not exist.";
}
}
else
{
echo "You must be logged in to delete this image.";
}
?>

+ 29
- 11
walls/main.php View File

@@ -1,5 +1,5 @@
<!-- The Bootstrap Image Gallery lightbox, should be a child element of the document body -->
<div id="blueimp-gallery" class="blueimp-gallery">
<div id="blueimp-gallery" class="blueimp-gallery" data-use-bootstrap-modal="false">
<!-- The container for the modal slides -->
<div class="slides"></div>
<!-- Controls for the borderless lightbox -->
@@ -32,14 +32,32 @@
</div>
</div>
</div>
<div id="links">
<a href="<?php echo get_page_url("cdn", $CONF); ?>/<?php echo $CONF['template']; ?>/img/screenshots/blog_screenshot.PNG" title="Banana" data-gallery>
<img src="<?php echo get_page_url("cdn", $CONF); ?>/<?php echo $CONF['template']; ?>/img/screenshots/blog_screenshot.PNG" alt="Banana">
</a>
<a href="<?php echo get_page_url("cdn", $CONF); ?>/<?php echo $CONF['template']; ?>/img/screenshots/paste_screenshot.PNG" title="Apple" data-gallery>
<img src="<?php echo get_page_url("cdn", $CONF); ?>/<?php echo $CONF['template']; ?>/img/screenshots/paste_screenshot.PNG" alt="Apple">
</a>
<a href="<?php echo get_page_url("cdn", $CONF); ?>/<?php echo $CONF['template']; ?>/img/screenshots/podcast_screenshot.PNG" title="Orange" data-gallery>
<img src="<?php echo get_page_url("cdn", $CONF); ?>/<?php echo $CONF['template']; ?>/img/screenshots/podcast_screenshot.PNG" alt="Orange">
</a>
<div class="conatainer">
<?php
if ($logged_in)
{
?>
<div class="row">
<center>
<button type="button" class="btn btn-primary" id="uploader">Add Wallpaper</button>
</center>
</div>
<?php
}
?>
<div class="row">
<div class="col-sm-12 text-center">
<div id="links">
<a href="<?php echo get_page_url("cdn", $CONF); ?>/<?php echo $CONF['template']; ?>/img/screenshots/blog_screenshot.PNG" title="Banana" data-gallery>
<img src="<?php echo get_page_url("cdn", $CONF); ?>/<?php echo $CONF['template']; ?>/img/screenshots/blog_screenshot_thumb.png" alt="Banana">
</a>
<a href="<?php echo get_page_url("cdn", $CONF); ?>/<?php echo $CONF['template']; ?>/img/screenshots/paste_screenshot.PNG" title="Apple" data-gallery>
<img src="<?php echo get_page_url("cdn", $CONF); ?>/<?php echo $CONF['template']; ?>/img/screenshots/paste_screenshot_thumb.png" alt="Apple">
</a>
<a href="<?php echo get_page_url("cdn", $CONF); ?>/<?php echo $CONF['template']; ?>/img/screenshots/podcast_screenshot.PNG" title="Orange" data-gallery>
<img src="<?php echo get_page_url("cdn", $CONF); ?>/<?php echo $CONF['template']; ?>/img/screenshots/podcast_screenshot_thumb.png" alt="Orange">
</a>
</div>
</div>
</div>
</div>

Loading…
Cancel
Save