This commit is contained in:
2019-05-31 11:39:03 -04:00
parent 016e26e580
commit d4271e9e90
9 changed files with 188 additions and 0 deletions
+37
View File
@@ -0,0 +1,37 @@
.DS_Store
application/cache/*
!application/cache/index.html
!application/cache/.htaccess
application/logs/*
!application/logs/index.html
!application/logs/.htaccess
user_guide_src/build/*
user_guide_src/cilexer/build/*
user_guide_src/cilexer/dist/*
user_guide_src/cilexer/pycilexer.egg-info/*
/vendor/
# IDE Files
#-------------------------
/nbproject/
.idea/*
## Sublime Text cache files
*.tmlanguage.cache
*.tmPreferences.cache
*.stTheme.cache
*.sublime-workspace
*.sublime-project
.svn/
*.sql
www/media/svid/
www/media/videos/
www/vendor/
www/composer.lock
wrenchboard/src/autom4te.cache/
wrenchboard/src/build/
wrenchboard/src/modules/
+5
View File
@@ -0,0 +1,5 @@
RewriteEngine on
#RewrtieBase /cards/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?path=$1 [NC,L,QSA]
Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

+79
View File
@@ -0,0 +1,79 @@
<?php
$path = $_GET['path'];
$size = isset($_GET['size'])?$_GET['size']:NULL;
define('BASEPATH', getcwd());
chdir('../../adminsavvy/');
chdir('/home/savvy/savvy/adminsavvy'); // DEBUG
require 'backend.php';
require 'application/libraries/Googlestorage.php';
$uniqueId = pathinfo($path, PATHINFO_FILENAME);
$objectName = pathinfo($path, PATHINFO_BASENAME);
$host = $savvyext->cfgReadChar('database.host');
$name = $savvyext->cfgReadChar('database.name');
$user = $savvyext->cfgReadChar('database.user');
$pass = $savvyext->cfgReadChar('database.pass');
$port = $savvyext->cfgReadLong('database.port');
$dbconn = pg_connect("host=${host} port=${port} dbname=${name} user=${user} password=${pass}");
if (!$dbconn) {
// Show error
showfile('errorspy.jpg');
}
$q = "select a.*,b.name as bucket from card_images a left join card_image_category b on (b.id=a.catid) where a.uniqueid = '".pg_escape_string($uniqueId)."'";
$r = pg_query($q);
if ($r && pg_num_rows($r) && $f=pg_fetch_assoc($r)) {
$image = $f;
} else {
// Show not found
showFile('image_not_found.png');
}
$storage = new GoogleStorage();
$storage->Init(
$savvyext->cfgReadChar('google.storage_project_id'),
$savvyext->cfgReadChar('google.storage_auth_file')
);
try {
$data = $storage->DownloadObject($image['bucket'],$objectName);
header('Content-type: image/'.$image['format']);
if ($size!=NULL && preg_match('/^([0-9]{2,4})x([0-9]{2,4})$/i', $size, $resize)==1
&& count($resize)>2 && ((int)$resize[1])>0 && ((int)$resize[2])>0) {
$temp_file = tempnam(sys_get_temp_dir(), $uniqueId);
file_put_contents($temp_file, $data);
require(BASEPATH.'/simple_image.php');
$resized = new SimpleImage();
$resized->load($temp_file);
$resized->resize($resize[1], $resize[2]);
$resized->output();
unlink($temp_file);
} else {
echo $data;
}
} catch (Exception $e) {
showFile('error.png');
/*
foreach ($storage->ListBuckets()as $b) {
echo $b->name()."<br>";
}
var_dump($storage->ListObjects($image['bucket']));
*/
}
function showFile($file,$path=BASEPATH) {
header('Content-type: '.mime_content_type($path.'/'.$file));
echo (file_get_contents($path.'/'.$file));
exit();
}
/*
$file = 'feed1.jpg';
header('Content-type: '.mime_content_type($file));
echo (file_get_contents($file));
*/
pg_close($dbconn);
+67
View File
@@ -0,0 +1,67 @@
<?
class SimpleImage {
var $image;
var $image_type;
function load($filename) {
$image_info = getimagesize($filename);
$this->image_type = $image_info[2];
if( $this->image_type == IMAGETYPE_JPEG ) {
$this->image = imagecreatefromjpeg($filename);
} elseif( $this->image_type == IMAGETYPE_GIF ) {
$this->image = imagecreatefromgif($filename);
} elseif( $this->image_type == IMAGETYPE_PNG ) {
$this->image = imagecreatefrompng($filename);
}
}
function save($filename, $image_type=IMAGETYPE_JPEG, $compression=75, $permissions=null) {
if( $image_type == IMAGETYPE_JPEG ) {
imagejpeg($this->image,$filename,$compression);
} elseif( $image_type == IMAGETYPE_GIF ) {
imagegif($this->image,$filename);
} elseif( $image_type == IMAGETYPE_PNG ) {
imagepng($this->image,$filename);
}
if( $permissions != null) {
chmod($filename,$permissions);
}
}
function output($image_type=IMAGETYPE_JPEG) {
if( $image_type == IMAGETYPE_JPEG ) {
imagejpeg($this->image);
} elseif( $image_type == IMAGETYPE_GIF ) {
imagegif($this->image);
} elseif( $image_type == IMAGETYPE_PNG ) {
imagepng($this->image);
}
}
function getWidth() {
return imagesx($this->image);
}
function getHeight() {
return imagesy($this->image);
}
function resizeToHeight($height) {
$ratio = $height / $this->getHeight();
$width = $this->getWidth() * $ratio;
$this->resize($width,$height);
}
function resizeToWidth($width) {
$ratio = $width / $this->getWidth();
$height = $this->getheight() * $ratio;
$this->resize($width,$height);
}
function scale($scale) {
$width = $this->getWidth() * $scale/100;
$height = $this->getheight() * $scale/100;
$this->resize($width,$height);
}
function resize($width,$height) {
$new_image = imagecreatetruecolor($width, $height);
imagecopyresampled($new_image, $this->image, 0, 0, 0, 0, $width, $height, $this->getWidth(), $this->getHeight());
$this->image = $new_image;
}
}
View File