Browse Source

Added image manipulation files

tags/v1.3
Teknikode 5 years ago
parent
commit
6ee47ea3b8
3 changed files with 148 additions and 0 deletions
  1. 45
    0
      templates/default/js/walls.js
  2. 63
    0
      walls/add_image.php
  3. 40
    0
      walls/delete_image.php

+ 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
});
});
});

+ 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.";
}
?>

Loading…
Cancel
Save