diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..1598dbb5 --- /dev/null +++ b/.gitignore @@ -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/ \ No newline at end of file diff --git a/resources/cards/.htaccess b/resources/cards/.htaccess new file mode 100644 index 00000000..15b2e451 --- /dev/null +++ b/resources/cards/.htaccess @@ -0,0 +1,5 @@ +RewriteEngine on +#RewrtieBase /cards/ +RewriteCond %{REQUEST_FILENAME} !-f +RewriteCond %{REQUEST_FILENAME} !-d +RewriteRule ^(.*)$ index.php?path=$1 [NC,L,QSA] diff --git a/resources/cards/error.png b/resources/cards/error.png new file mode 100644 index 00000000..e9926ced Binary files /dev/null and b/resources/cards/error.png differ diff --git a/resources/cards/errorspy.jpg b/resources/cards/errorspy.jpg new file mode 100644 index 00000000..f35d1ef2 Binary files /dev/null and b/resources/cards/errorspy.jpg differ diff --git a/resources/cards/feed1.jpg b/resources/cards/feed1.jpg new file mode 100644 index 00000000..814008e6 Binary files /dev/null and b/resources/cards/feed1.jpg differ diff --git a/resources/cards/image_not_found.png b/resources/cards/image_not_found.png new file mode 100644 index 00000000..4622555e Binary files /dev/null and b/resources/cards/image_not_found.png differ diff --git a/resources/cards/index.php b/resources/cards/index.php new file mode 100644 index 00000000..943102cd --- /dev/null +++ b/resources/cards/index.php @@ -0,0 +1,79 @@ +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()."
"; + } + 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); diff --git a/resources/cards/simple_image.php b/resources/cards/simple_image.php new file mode 100644 index 00000000..c26d83da --- /dev/null +++ b/resources/cards/simple_image.php @@ -0,0 +1,67 @@ +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; + } +} + diff --git a/resources/index.php b/resources/index.php new file mode 100644 index 00000000..e69de29b