Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
website
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sam
website
Commits
18e13353
Commit
18e13353
authored
7 years ago
by
Naszlady Márton Bese
Browse files
Options
Downloads
Patches
Plain Diff
Implemented image fetching from db.
parent
8d887fab
No related branches found
Tags
archive/kibusam
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
image.php
+51
-23
51 additions, 23 deletions
image.php
with
51 additions
and
23 deletions
image.php
+
51
−
23
View file @
18e13353
<?php
<?php
ob_start
(
"ob_gzhandler"
);
// Example url:
// http://kibusam.itk.ppke.hu/image.php?thumbnail&1190
require
(
'./core/backend.php'
);
$username
=
$_SESSION
[
'user'
];
$uri
=
$_SERVER
[
'QUERY_STRING'
];
$uri
=
$_SERVER
[
'QUERY_STRING'
];
$uri_parts
=
explode
(
'&'
,
$uri
);
$uri_parts
=
explode
(
'&'
,
$uri
);
$path
=
"/home/hakta/public_html/belepteto/images/"
.
$uri_parts
[
0
];
$path
=
"/home/hakta/public_html/belepteto/images/"
.
$uri_parts
[
0
];
header
(
'Content-type: image/jpeg'
);
if
(
!
in_array
(
$uri_parts
[
0
],
array
(
'thumbnail'
,
'photo'
)))
{
header
(
'Accept-Ranges: bytes'
);
die
(
'Not valid request!'
);
}
$pic_ID
=
intval
(
$uri_parts
[
1
]);
if
(
$uri_parts
[
0
]
==
"thumbnail"
)
{
$result
=
$db
->
prepare
(
'
SELECT thumbnail_img
FROM thumbnail t
INNER JOIN annotation a ON a.thumbnail_ID = t.thumbnail_ID
INNER JOIN user u ON u.card_ID = a.card_ID
WHERE t.thumbnail_ID=:picid AND u.name=:username'
);
$result
->
execute
(
array
(
'username'
=>
$username
,
'picid'
=>
$pic_ID
));
$result
=
$result
->
fetch
(
PDO
::
FETCH_NUM
);
if
(
$result
[
0
])
{
header
(
'Content-type: image/jpeg'
);
die
(
$result
[
0
]);
}
}
elseif
(
$uri_parts
[
0
]
==
"photo"
)
{
$result
=
$db
->
prepare
(
'
SELECT photo_img
FROM photo p
INNER JOIN thumbnail t ON p.photo_ID = t.photo_ID
INNER JOIN annotation a ON a.thumbnail_ID = t.thumbnail_ID
INNER JOIN user u ON u.card_ID = a.card_ID
WHERE t.thumbnail_ID=:picid AND u.name=:username'
);
$result
->
execute
(
array
(
'username'
=>
$username
,
'picid'
=>
$pic_ID
));
$result
=
$result
->
fetch
(
PDO
::
FETCH_NUM
);
if
(
$result
[
0
])
{
header
(
'Content-type: image/jpeg'
);
die
(
$result
[
0
]);
}
}
exit
;
//header('Content-type: image/jpeg');
//header('Accept-Ranges: bytes');
//header('Content-Length: ' . filesize($path));
//header('Content-Length: ' . filesize($path));
header
(
'Last-Modified: '
.
gmdate
(
'D, d M Y H:i:s'
,
filemtime
(
$path
))
.
' GMT'
);
//header('Last-Modified: '.gmdate('D, d M Y H:i:s', filemtime($path)).' GMT');
$seconds_to_cache
=
31536000
;
//header('Expires: '.gmdate('D, d M Y H:i:s', time()+$seconds_to_cache).' GMT');
header
(
'Expires: '
.
gmdate
(
'D, d M Y H:i:s'
,
time
()
+
$seconds_to_cache
)
.
' GMT'
);
//header('Pragma: cache');
header
(
'Pragma: cache'
);
//header('Cache-Control: max-age='.$seconds_to_cache);
header
(
'Cache-Control: max-age='
.
$seconds_to_cache
);
//header('Vary: Accept-Encoding');
header
(
'Vary: Accept-Encoding'
);
//header('Content-Encoding: gzip');
//header('Content-Encoding: gzip');
header_remove
(
'x-powered-by'
);
//header_remove('x-powered-by');
\ No newline at end of file
//readfile($path);die();
$image
=
imagecreatefromjpeg
(
$path
);
if
(
count
(
$uri_parts
)
>
1
)
{
list
(
$width
,
$height
)
=
getimagesize
(
$path
);
$new_width
=
(
int
)
$uri_parts
[
1
];
$new_height
=
$new_width
/
$width
*
$height
;
$tmp
=
imagecreatetruecolor
(
$new_width
,
$new_height
);
imagecopyresampled
(
$tmp
,
$image
,
0
,
0
,
0
,
0
,
$new_width
,
$new_height
,
$width
,
$height
);
}
else
{
$tmp
=
$image
;
}
imagejpeg
(
$tmp
,
NULL
,
85
);
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment