);
serendipity_ACL_SQL($cond, false, 'directory');
- $basequery = "FROM {$serendipity['dbPrefix']}images AS i
- LEFT OUTER JOIN {$serendipity['dbPrefix']}authors AS a
- ON i.authorid = a.authorid
+ $basequery = "FROM {$serendipity['dbPrefix']}images AS i
+ LEFT OUTER JOIN {$serendipity['dbPrefix']}authors AS a
+ ON i.authorid = a.authorid
{$cond['joins']}
-
+
{$cond['and']}";
-
- $query = "SELECT i.*,
- a.realname AS authorname
- $basequery
+
+ $query = "SELECT i.*,
+ a.realname AS authorname
+ $basequery
ORDER BY $order $ordermode $limitsql";
$rs = serendipity_db_query($query, false, 'assoc');
return array();
}
- $total_query = "SELECT count(i.id)
+ $total_query = "SELECT count(i.id)
$basequery";
$total_rs = serendipity_db_query($total_query, true, 'num');
if (is_array($total_rs)) {
*/
function serendipity_fetchImageFromDatabase($id) {
global $serendipity;
-
+
$cond = array(
'and' => "WHERE id = " . (int)$id
);
serendipity_ACL_SQL($cond, false, 'directory');
- $rs = serendipity_db_query("SELECT i.*
+ $rs = serendipity_db_query("SELECT i.*
FROM {$serendipity['dbPrefix']}images AS i
{$cond['joins']}
{$cond['and']}", true, 'assoc');
);
serendipity_ACL_SQL($cond, false, 'directory');
- $rs = serendipity_db_query("SELECT *
+ $rs = serendipity_db_query("SELECT *
FROM {$serendipity['dbPrefix']}images AS i
{$cond['joins']}
-
+
{$cond['and']}", true, 'assoc');
if (is_array($rs)) {
$update = array();
case 'gif':
$func['load'] = 'imagecreatefromgif';
$func['save'] = 'imagegif';
+ $func['qual'] = 100;
break;
case 'jpeg':
case 'jfif':
$func['load'] = 'imagecreatefromjpeg';
$func['save'] = 'imagejpeg';
+ $func['qual'] = 100;
break;
case 'png':
$func['load'] = 'imagecreatefrompng';
$func['save'] = 'imagepng';
+ $func['qual'] = 9;
break;
default:
$in = $func['load']($infilename);
$out = imagerotate($in, $degrees, 0);
- $func['save']($out, $outfilename);
+ $func['save']($out, $outfilename, $func['qual']);
$newwidth = imagesx($out);
$newheight = imagesy($out);
}
imagecopyresampled($out, $in, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
- $func['save']($out, $outfilename, 100);
+ $func['save']($out, $outfilename, $func['qual']);
$out = null;
$in = null;
$aFilesOnDisk = array();
$aResultSet = serendipity_traversePath(
- $serendipity['serendipityPath'] . $serendipity['uploadPath']. $limit_path,
- '',
- false,
- NULL,
- 1,
- NULL,
+ $serendipity['serendipityPath'] . $serendipity['uploadPath']. $limit_path,
+ '',
+ false,
+ NULL,
+ 1,
+ NULL,
FALSE,
$aExclude
);
// MTG 21/01/06: request all images from the database, delete any which don't exist
// on the filesystem, and mark off files from the file list which are already
// in the database
-
+
$nCount = 0;
if ($serendipity['onTheFlySynch'] && serendipity_checkPermission('adminImagesSync') && $serendipity['current_image_hash'] != $serendipity['last_image_hash']) {
- $aResultSet = serendipity_db_query("SELECT path, name, extension, thumbnail_name, id
+ $aResultSet = serendipity_db_query("SELECT path, name, extension, thumbnail_name, id
FROM {$serendipity['dbPrefix']}images", false, 'assoc');
if ($debug) echo "<p>Got images: <pre>" . print_r($aResultSet, true) . "</pre></p>";
if (is_array($aResultSet)) {
- foreach ($aResultSet AS $sKey => $sFile) {
+ foreach ($aResultSet AS $sKey => $sFile) {
serendipity_plugin_api::hook_event('backend_thumbnail_filename_select', $sFile);
$sThumbNailFile = '';
if (isset($sFile['thumbnail_filename'])) {
if ($debug) echo "<p>Cleaned up ".$nCount." database entries</p>";
}
- serendipity_set_config_var('last_image_hash', $serendipity['current_image_hash'], 0);
- $aUnmatchedOnDisk = array_keys($aFilesOnDisk);
+ serendipity_set_config_var('last_image_hash', $serendipity['current_image_hash'], 0);
+ $aUnmatchedOnDisk = array_keys($aFilesOnDisk);
if ($debug) echo "<p>Got unmatched files: <pre>" . print_r($aUnmatchedOnDisk, true) . "</pre></p>";
$nCount = 0;
foreach ($aUnmatchedOnDisk AS $sFile) {
} else {
if ($debug) echo "<p>Checking $sFile</p>";
}
-
+
// MTG: 21/01/06: put files which have just 'turned up' into the database
$aImageData = serendipity_getImageData($sFile);
if (serendipity_isImage($aImageData)) {
## Aply ACL afterwards:
serendipity_directoryACL($paths, 'read');
-
+
$serendipity['imageList'] = serendipity_fetchImagesFromDatabase(
$start,
$perPage,
while (($file = @readdir($dh)) !== false) {
if ($file != '.' && $file != '..') {
$bPatternMatch = (is_null($pattern) || preg_match($pattern, $file));
- $sFullPath = $odir . $file;
+ $sFullPath = $odir . $file;
$bIsDir = is_dir($sFullPath);
if ($onlyDirs === false || $bIsDir) {
if ($bPatternMatch &&
}
@closedir($dh);
-
+
if ($depth == 1 && $apply_ACL !== FALSE) {
serendipity_directoryACL($files, $apply_ACL);
}
$dir .= '/';
}
}
-
+
return $dir;
}
function serendipity_directoryACL(&$paths, $type = 'read') {
global $serendipity;
static $debug = false;
-
+
if ($debug) {
echo "Applying ACL for mode '$type'.<br />\n";
}
-
+
if (!is_array($paths)) {
return true;
}
return true;
}
}
-
+
// Get list of all ACLs for directories.
$q = "SELECT a.artifact_index AS directory,
a.groupid
if (!is_array($allowed)) {
return true;
}
-
+
// Get a list of all the groups for this user. Pipe it into a usable array.
$my_groups =& serendipity_getGroups($serendipity['authorid']);
$acl_allowed_groups = array();
foreach($my_groups AS $my_group) {
$acl_allowed_groups[$my_group['id']] = true;
}
-
+
// Iterate every ACL and check if we are allowed to use it.
$acl_allowed = array();
foreach($allowed AS $row) {
$acl_allowed[$row['directory']][$row['groupid']] = true;
}
-
+
// Iterate the input path array and check it against ACL.
foreach($paths AS $idx => $info) {
if (!isset($acl_allowed[$info['relpath']])) {
// ACL for directory not set. Assume we are allowed to access.
continue;
}
-
+
$granted = false;
foreach($acl_allowed[$info['relpath']] AS $groupid => $set) {
if (isset($acl_allowed_groups[$groupid])) {
break;
}
}
-
+
if ($granted === false) {
// We are not allowed to access this element
if ($debug) {
}
}
}
-
+
if (count($paths) < $startCount) {
if ($debug) {
echo "ACL denied all.<br />\n";
return false;
}
}
-
+
return true;
}
}
/**
- * Given a relative path to an image, construct an array containing all
+ * Given a relative path to an image, construct an array containing all
* relevant information about that image in the file structure.
*
* @author MTG
'hotlink' => 0,
'id' => $sRelativePath
);
-
+
return $array;
}