Ejemplo n.º 1
0
}
$item = null;
if (isset($_POST['id'])) {
    $item = $db->selectObject('imagemanageritem', 'id=' . intval($_POST['id']));
    if ($item) {
        $loc = unserialize($item->location_data);
    }
}
if ($item == null && exponent_permissions_check('post', $loc) || $item != null && exponent_permissions_check('edit', $loc)) {
    // unset the image cache
    unset($_SESSION['image_cache']);
    // check for real images.
    $filenew = $_FILES['file']['tmp_name'];
    $fileup = getimagesize($filenew);
    if ($fileup[2] > 0 && $fileup[1] > 0) {
        $item = imagemanageritem::update($_POST, $item);
        $item->location_data = serialize($loc);
        if (!isset($item->id)) {
            if (!defined('SYS_FILES')) {
                include_once BASE . 'subsystems/files.php';
            }
            $directory = 'files/imagemanagermodule/' . $loc->src;
            $fname = null;
            if (exponent_files_uploadDestinationFileExists($directory, 'file')) {
                // Auto-uniqify Logic here
                $fileinfo = pathinfo($_FILES['file']['name']);
                $fileinfo['extension'] = '.' . $fileinfo['extension'];
                do {
                    $fname = basename($fileinfo['basename'], $fileinfo['extension']) . uniqid('') . $fileinfo['extension'];
                } while (file_exists(BASE . $directory . '/' . $fname));
            }
# PURPOSE.  See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU
# General Public License along with Exponent; if
# not, write to:
#
# Free Software Foundation, Inc.,
# 59 Temple Place,
# Suite 330,
# Boston, MA 02111-1307  USA
#
# $Id: imgmgr_save.php,v 1.1 2005/04/18 01:27:23 filetreefrog Exp $
##################################################
if (!defined('PATHOS')) {
    exit('');
}
// PERM CHECK
$item = imagemanageritem::update($_POST, null);
$item->location_data = serialize(pathos_core_makeLocation('imagemanagermodule', $_POST['imgmgr_src']));
$file = $db->selectObject('file', 'id=' . $_POST['file_id']);
$new_dir = 'files/imagemanagermodule/' . $_POST['imgmgr_src'];
$new_file = time() . '_' . $file->filename;
copy(BASE . $file->directory . '/' . $file->filename, BASE . $new_dir . '/' . $new_file);
$file->directory = $new_dir;
$file->filename = $new_file;
unset($file->id);
$item->file_id = $db->insertObject($file, 'file');
$db->insertObject($item, 'imagemanageritem');
#echo '<script type="text/javascript">alert("Image Copied Successfully!"); window.close();</script>';
// END PERM CHECK