From: <sy...@us...> - 2007-04-02 16:32:48
|
Update of /cvsroot/tikiwiki/tiki/lib/imagegals In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv11276/lib/imagegals Modified Files: imagegallib.php Log Message: [MOD]fgal: can edit a file - still a bug - need to refresh the browser cache to see the new image Index: imagegallib.php =================================================================== RCS file: /cvsroot/tikiwiki/tiki/lib/imagegals/imagegallib.php,v retrieving revision 1.90 retrieving revision 1.91 diff -u -d -r1.90 -r1.91 --- imagegallib.php 12 Feb 2007 11:12:55 -0000 1.90 +++ imagegallib.php 2 Apr 2007 16:31:42 -0000 1.91 @@ -793,12 +793,34 @@ } } - function edit_image($id, $name, $description,$lat=NULL,$lon=NULL) { + function edit_image($id, $name, $description, $lat=NULL, $lon=NULL, $file=NULL) { + global $gal_use_db, $gal_use_dir; $name = strip_tags($name); $description = strip_tags($description); $query = "update `tiki_images` set `name`=?, `description`=?, `lat`=?, `lon`=? where `imageId` = ?"; $result = $this->query($query,array($name,$description,$lat,$lon,(int)$id)); + if (!empty($file) && !empty($file['name'])) { + if (!is_uploaded_file($file['tmp_name']) || !($fp = fopen($file['tmp_name'], "rb"))) + return false; + $data = fread($fp, $file['size']); + $etag = md5($data); + fclose($fp); + if ($gal_use_db == 'y') { + $query = "update `tiki_images_data` set `data`=?, `etag`=?, `filename`=? where `imageId` = ? and `type`=?"; + $result = $this->query($query,array($data, $etag, $file['name'], (int)$id, 'o')); + } else { + $query = "select `path` from `tiki_images` where `imageId`=?"; + $path = $this->getOne($query, $id); + if (!move_uploaded_file($file['tmp_name'], $gal_use_dir.$path)) { + return false; + } + $query = "update `tiki_images_data` set `etag`=?,`filename`=? where `imageId` = ? and `type`=?"; + $result = $this->query($query,array($etag, $file['name'], (int)$id, 'o')); + } + $query = "delete from `tiki_images_data` where `imageId`=? and `type`!=?"; + $result = $this->query($query, array((int)$id, 'o')); + } return true; } |