getExtension() helper
This commit is contained in:
parent
69aa61cade
commit
404b519747
@ -292,8 +292,7 @@ class Album extends Module {
|
||||
if (!@is_readable($photo->url)) continue;
|
||||
|
||||
# Get extension of image
|
||||
$extension = array_reverse(explode('.', $photo->url));
|
||||
$extension = $extension[0];
|
||||
$extension = getExtension($photo->url);
|
||||
|
||||
# Set title for photo
|
||||
$zipFileName = $zipTitle . '/' . $photo->title . '.' . $extension;
|
||||
@ -304,7 +303,7 @@ class Album extends Module {
|
||||
while (in_array($zipFileName, $files)) {
|
||||
|
||||
# Set new title for photo
|
||||
$zipFileName = $zipTitle . '/' . $photo->title . '-' . $i . '.' . $extension;
|
||||
$zipFileName = $zipTitle . '/' . $photo->title . '-' . $i . $extension;
|
||||
|
||||
$i++;
|
||||
|
||||
|
@ -78,7 +78,7 @@ class Photo extends Module {
|
||||
foreach ($files as $file) {
|
||||
|
||||
# Verify extension
|
||||
$extension = $this->getExtension($file['name']);
|
||||
$extension = getExtension($file['name']);
|
||||
if (!in_array(strtolower($extension), $this->validExtensions, true)) continue;
|
||||
|
||||
# Verify image
|
||||
@ -517,7 +517,7 @@ class Photo extends Module {
|
||||
$photo = $photos->fetch_object();
|
||||
|
||||
# Get extension
|
||||
$extension = $this->getExtension($photo->url);
|
||||
$extension = getExtension($photo->url);
|
||||
if ($extension===false) {
|
||||
Log::error($this->database, __METHOD__, __LINE__, 'Invalid photo extension');
|
||||
return false;
|
||||
@ -541,16 +541,6 @@ class Photo extends Module {
|
||||
|
||||
}
|
||||
|
||||
public function getExtension($filename) {
|
||||
|
||||
$extension = strpos($filename, '.') !== false
|
||||
? strrchr($filename, '.')
|
||||
: '';
|
||||
|
||||
return $extension;
|
||||
|
||||
}
|
||||
|
||||
public function setTitle($title) {
|
||||
|
||||
# Check dependencies
|
||||
|
@ -9,36 +9,6 @@
|
||||
|
||||
if (!defined('LYCHEE')) exit('Error: Direct access is not allowed!');
|
||||
|
||||
function getGraphHeader($database, $photoID) {
|
||||
|
||||
if (!isset($database, $photoID)) return false;
|
||||
|
||||
$photoID = mysqli_real_escape_string($database, $photoID);
|
||||
|
||||
$result = $database->query("SELECT title, description, url FROM lychee_photos WHERE id = '$photoID';");
|
||||
$row = $result->fetch_object();
|
||||
|
||||
$parseUrl = parse_url("http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
|
||||
$picture = $parseUrl['scheme']."://".$parseUrl['host'].$parseUrl['path']."/../uploads/big/".$row->url;
|
||||
|
||||
$return = '<!-- General Meta Data -->';
|
||||
$return .= '<meta name="title" content="'.$row->title.'" />';
|
||||
$return .= '<meta name="description" content="'.$row->description.' - via Lychee" />';
|
||||
$return .= '<link rel="image_src" type="image/jpeg" href="'.$picture.'" />';
|
||||
|
||||
$return .= '<!-- Twitter Meta Data -->';
|
||||
$return .= '<meta name="twitter:card" content="photo">';
|
||||
$return .= '<meta name="twitter:title" content="'.$row->title.'">';
|
||||
$return .= '<meta name="twitter:image:src" content="'.$picture.'">';
|
||||
|
||||
$return .= '<!-- Facebook Meta Data -->';
|
||||
$return .= '<meta property="og:title" content="'.$row->title.'">';
|
||||
$return .= '<meta property="og:image" content="'.$picture.'">';
|
||||
|
||||
return $return;
|
||||
|
||||
}
|
||||
|
||||
function search($database, $settings, $term) {
|
||||
|
||||
if (!isset($database, $settings, $term)) return false;
|
||||
@ -80,6 +50,46 @@ function search($database, $settings, $term) {
|
||||
|
||||
}
|
||||
|
||||
function getGraphHeader($database, $photoID) {
|
||||
|
||||
if (!isset($database, $photoID)) return false;
|
||||
|
||||
$photoID = mysqli_real_escape_string($database, $photoID);
|
||||
|
||||
$result = $database->query("SELECT title, description, url FROM lychee_photos WHERE id = '$photoID';");
|
||||
$row = $result->fetch_object();
|
||||
|
||||
$parseUrl = parse_url("http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
|
||||
$picture = $parseUrl['scheme']."://".$parseUrl['host'].$parseUrl['path']."/../uploads/big/".$row->url;
|
||||
|
||||
$return = '<!-- General Meta Data -->';
|
||||
$return .= '<meta name="title" content="'.$row->title.'" />';
|
||||
$return .= '<meta name="description" content="'.$row->description.' - via Lychee" />';
|
||||
$return .= '<link rel="image_src" type="image/jpeg" href="'.$picture.'" />';
|
||||
|
||||
$return .= '<!-- Twitter Meta Data -->';
|
||||
$return .= '<meta name="twitter:card" content="photo">';
|
||||
$return .= '<meta name="twitter:title" content="'.$row->title.'">';
|
||||
$return .= '<meta name="twitter:image:src" content="'.$picture.'">';
|
||||
|
||||
$return .= '<!-- Facebook Meta Data -->';
|
||||
$return .= '<meta property="og:title" content="'.$row->title.'">';
|
||||
$return .= '<meta property="og:image" content="'.$picture.'">';
|
||||
|
||||
return $return;
|
||||
|
||||
}
|
||||
|
||||
function getExtension($filename) {
|
||||
|
||||
$extension = strpos($filename, '.') !== false
|
||||
? strrchr($filename, '.')
|
||||
: '';
|
||||
|
||||
return $extension;
|
||||
|
||||
}
|
||||
|
||||
function get_hashed_password($password) {
|
||||
|
||||
# Inspired by http://alias.io/2010/01/store-passwords-safely-with-php-and-mysql/
|
||||
|
Loading…
Reference in New Issue
Block a user